//
//  TaskDetailViewController.m
//  MobileOffice
//
//  Created by jjkj on 16/11/21.
//  Copyright © 2016年 liaoningjujin. All rights reserved.
//

#import "TaskDetailViewController.h"
#import "InstitutionListModel.h"
#import "PromptView.h"
#import "PersonMessageViewController.h"
#import "TaskDetailModel.h"
#import "TaskDetailTableViewCell.h"
#import "OffDetailViewController.h"
#import "FamilyLeaveDetailViewController.h"
#import "InjuryDetailViewController.h"
#import "YearDetailViewController.h"
#import "MaternityDetailViewController.h"
#import "FuneralDetailViewController.h"
#import "MarriageDetailViewController.h"
#import "PersonalDetailViewController.h"
#import "SickDetailViewController.h"
#import "DutyListViewController.h"
#import "DutyOvertimeViewController.h"
#import "GoOutApplyViewController.h"
#import "SignInAbnormalViewController.h"
#import "DutyGoBackViewController.h"
#import "DutyGoBackViewController.h"
#import "ImageDetailViewController.h"
#import "EndHolidayViewController.h"
#import "PersonGoOutDetailViewController.h"
#import "PersonInfoDetailViewController.h"


#define getApproveCourseList @"getApproveCourseList"//审批历程（时间轴）
#define getManagementInfo @"getManagementInfo"//获取制度详细信息
#define getCountdownTimeInfo @"getCountdownTimeInfo"//获取倒计时间
#define postApproveInfo @"postApproveInfo"//审批驳回接口
#define postDeleteVacateBill @"postDeleteVacateBill"//撤销请假信息
#define postDeleteBiz @"postDeleteBiz" //撤销公出申请、加班申请、异常解释
#define postApproveNewFlowInfo @"postApproveNewFlowInfo"//审批同意/驳回
#define postSHInfo @"postSHInfo"//提交公出汇报审核
#define postVerifyEliminateInfo @"postVerifyEliminateInfo"//提交核销确认信息


#define TEXTVIEWMESSAGE_AGREE @"该信息符合要求,同意。"//同意
#define TEXTVIEWMESSAGE_DISAGREE @"该信息不符合要求,驳回。"//不同意
#define TEXTVIEWMESSAGE_VERIFY @"该信息需要进行考核。"//事假考核

@interface TaskDetailViewController ()<UITextViewDelegate,UITableViewDelegate,UITableViewDataSource>
{
    InstitutionListModel *_institutionListModel;//功能列表
    PromptView *_promptView;//制度提示框
    UIView *_backMsgView;//消息textView的父视图
    UITextView *_msgTextView;//消息textView
    UITableView *_tableView;//列表
    CGFloat _oldOffset;//偏移量
    TaskDetailModel *_taskDetailModel;//
    NSInteger _minute;//分钟
    NSInteger _second;//秒
    NSTimer *_timer;//计时器
    UILabel *_timeLabel;//时间label
    CGFloat _viewHeight;//操作框的高度  如果没有则为0
}
@property (nonatomic,strong) NSMutableArray *heightArr;
@property (nonatomic,strong) NSArray *statusInfo;
@property (nonatomic,strong) NSString *empId;//用户编号
@property (nonatomic,strong) NSMutableDictionary *workDict;//保存委托人的label
@property (nonatomic,strong) NSMutableArray *photoArr;//保存照片的button
@property (nonatomic,strong) NSMutableArray *photoModelArr;//照片的model
@end

@implementation TaskDetailViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.type=@"2";
    self.heightArr=[NSMutableArray new];
    self.workDict=[NSMutableDictionary new];
    [self setRightBackNavigation];
    //增加监听，当键盘出现或改变时收出消息
    [[NSNotificationCenter defaultCenter] addObserver:self
                                             selector:@selector(keyboardWillShow:)
                                                 name:UIKeyboardWillShowNotification
                                               object:nil];
    
    //增加监听，当键退出时收出消息
    [[NSNotificationCenter defaultCenter] addObserver:self
                                             selector:@selector(keyboardWillHide:)
                                                 name:UIKeyboardWillHideNotification
                                               object:nil];
    // [self sendMessageWithText:@"asfasgasg"];

    if ([self.isOperate isEqualToString:@"1"]) {
        if ([self.businessCode isEqualToString:@"JB0011"]||[self.businessCode isEqualToString:@"YC0012"]) {
            //考核异常 加班
            if ([self.dealState isEqualToString:@"0"]) {
                if ([self.isOwn isEqualToString:@"0"]) {
                        // @"待审批";
                    [self setNavigationTitle:@"待审批"];
                    [self creatApproveTextView];
                    _viewHeight=129;
                } else if ([self.isOwn isEqualToString:@"1"]) {
                    // @"待审批";
                    [self setNavigationTitle:@"待审批"];
                    _viewHeight=0;
                }
            } else if ([self.dealState isEqualToString:@"1"]) {
                if ([self.isOwn isEqualToString:@"0"]) {
                    // @"待审批";
                    [self setNavigationTitle:@"待审批"];
                    _viewHeight=129;
                    [self creatApproveTextView];

                } else if ([self.isOwn isEqualToString:@"1"]) {
                    // @"待审批";
                    [self setNavigationTitle:@"待审批"];
                    _viewHeight=0;
                }
            } else if ([self.dealState isEqualToString:@"2"]) {
                // @"审批驳回";
                [self setNavigationTitle:@"驳回信息查看"];
                _viewHeight=90;
                [self creatEditTextView];
            } else if ([self.dealState isEqualToString:@"3"]) {
                // @"审批通过";
                [self setNavigationTitle:@"信息查看"];
                _viewHeight=0;
            }
        }else if ([self.businessCode isEqualToString:@"GC0009"]){
            //如果是公出
                if ([self.dealState isEqualToString:@"0"]) {
                    if ([self.isOwn isEqualToString:@"0"]) {
                        // @"待审批";
                        [self setNavigationTitle:@"待审批"];
                        [self creatApproveTextView];
                        _viewHeight=129;
                    } else if ([self.isOwn isEqualToString:@"1"]) {
                        [self setNavigationTitle:@"待审批"];
                        _viewHeight=0;
                        // @"待审批";
                    }
                } else if ([self.dealState isEqualToString:@"1"]) {
                    if ([self.isOwn isEqualToString:@"0"]) {
                        // @"待审批";
                        [self setNavigationTitle:@"公出审批"];
                        _viewHeight=129;
                        [self creatApproveTextView];
                    } else if ([self.isOwn isEqualToString:@"1"]) {
                        // @"待审批";
                        [self setNavigationTitle:@"待审批"];
                        _viewHeight=0;
                    }
                } else if ([self.dealState isEqualToString:@"2"]) {
                    // @"审批驳回";
                    [self setNavigationTitle:@"驳回信息查看"];
                    _viewHeight=90;
                    [self creatEditTextView];
                } else if ([self.dealState isEqualToString:@"3"]) {
                    // @"待汇报";
                    [self setNavigationTitle:@"汇报信息查看"];
                    _viewHeight=90;
                    [self creatReportTextView];
                } else if ([self.dealState isEqualToString:@"4"]) {
                    // @"汇报驳回";
                    [self setNavigationTitle:@"驳回信息查看"];
                    _viewHeight=90;
                    [self creatReportTextView];
                } else if ([self.dealState isEqualToString:@"5"]) {
                    if ([self.isOwn isEqualToString:@"0"]) {
                            // @"待审核";
                        [self setNavigationTitle:@"待审核"];
                        _viewHeight=129;
                        [self creatApproveTextView];
                    } else if ([self.isOwn isEqualToString:@"1"]) {
                        // @"待审核";
                        [self setNavigationTitle:@"待审核"];
                        _viewHeight=0;
                    }
                } else if ([self.dealState isEqualToString:@"6"]) {
                    // @"审核通过";
                    [self setNavigationTitle:@"审核通过"];
                    _viewHeight=0;
                }
        }else{
            //请假
            if ([self.dealState isEqualToString:@"0"]) {
                // @"草稿";
            } else if ([self.dealState isEqualToString:@"1"]) {
                if ([self.isOwn isEqualToString:@"0"]) {
                        // @"待审批";
                    [self setNavigationTitle:@"待审批"];
                    _viewHeight=129;
                    [self creatApproveTextView];
                } else if ([self.isOwn isEqualToString:@"1"]) {
                    // @"待审批";
                    [self setNavigationTitle:@"待审批"];
                    _viewHeight=0;
                }
            } else if ([self.dealState isEqualToString:@"2"]) {
                // @"审批驳回";
                [self setNavigationTitle:@"驳回信息查看"];
                _viewHeight=90;
                [self creatEditTextView];
            } else if ([self.dealState isEqualToString:@"3"]) {
                // @"待销假";
                [self setNavigationTitle:@"销假查看"];
                _viewHeight=90;
                [self creatEndHolidayTextView];
            } else if ([self.dealState isEqualToString:@"4"]) {
                // @"销假驳回";
                [self setNavigationTitle:@"销假查看"];
                _viewHeight=90;
                [self creatEndHolidayTextView];
            } else if ([self.dealState isEqualToString:@"5"]) {
                if ([self.isOwn isEqualToString:@"0"]) {
                        // @"待核销";
                    [self setNavigationTitle:@"待核销"];
                    _viewHeight=129;
                    [self creatVerifyTextView];
                } else if ([self.isOwn isEqualToString:@"1"]) {
                    // @"待核销";
                    [self setNavigationTitle:@"销假查看"];
                    _viewHeight=0;
                }
            } else if ([self.dealState isEqualToString:@"6"]) {
                // @"已核销";
                [self setNavigationTitle:@"已核销"];
                _viewHeight=0;
            }
        }
    }else{
        [self setNavigationTitle:@"信息查看"];
    }
    [self creatView];
    [self setLeftBackNavigation];
    [self setRightNavigation:@""];
    //[self creatHeaderView];
    [self getManagementInfoRequest];
    [self getApproveCourseListRequest];
    [self serverDateRequest];
    // Do any additional setup after loading the view.
}

- (NSMutableArray *)photoArr{
    if (!_photoArr) {
        _photoArr=[NSMutableArray new];
    }
    return _photoArr;
}

#pragma mark -个人信息view
- (void)creatHeaderView{

    
    self.view.backgroundColor=COLOR_BACKGROUND_GRAY;
    UIView *headView=[[UIView alloc]initWithFrame:CGRectMake(0, 0, IPHONE_WIDTH, 90)];
    headView.backgroundColor=COLOR_MIDBLUE;
    [self.view addSubview:headView];
    
    //头像
    UIImageView *headImageView=[MyControl creatImageViewWithFrame:CGRectMake(10, 10, 60, 60) imageName:@""];
    headImageView.layer.masksToBounds=YES;
    headImageView.layer.cornerRadius=headImageView.width/2;
    [headView addSubview:headImageView];
    
    UIImageView *statusImageView=[MyControl creatImageViewWithFrame:CGRectMake(34, 59, 46, 18) imageName:@"k_ic_ts_gcz.png"];
    [headView addSubview:statusImageView];
    
    //状态按钮
    UIButton *statusButton=[UIButton buttonWithType:UIButtonTypeCustom];
    statusButton.frame=CGRectMake(34, 55, 46, 28);
    statusButton.titleLabel.font=FONT_12;
    [statusButton addTarget:self action:@selector(personStatusClick) forControlEvents:UIControlEventTouchUpInside];
    [headView addSubview:statusButton];
    //姓名
    UILabel *nameLabel=[MyControl creatLabelWithFrame:CGRectMake(headImageView.x+headImageView.width+20, 15, IPHONE_WIDTH-(headImageView.x+headImageView.width+20)-8, 21) text:@""];

    nameLabel.textColor=[UIColor whiteColor];
    [headView addSubview:nameLabel];
    
    //职位
    UILabel *positionLabel=[MyControl creatLabelWithFrame:CGRectMake(nameLabel.x+nameLabel.width+8, 16, IPHONE_WIDTH-(nameLabel.x+nameLabel.width+8)-8, 21) text:@""];
    positionLabel.textColor=[UIColor whiteColor];
    positionLabel.font=[UIFont systemFontOfSize:12];
    [headView addSubview:positionLabel];
    
    //项目组
    UILabel *jobLabel=[MyControl creatLabelWithFrame:CGRectMake(nameLabel.x, nameLabel.y+nameLabel.height ,nameLabel.width, 21) text:@""];

    jobLabel.textColor=[UIColor whiteColor];
    jobLabel.font=FONT_13;
    [headView addSubview:jobLabel];
    
    //请假天数
    UILabel *holidaycountLabel=[MyControl creatLabelWithFrame:CGRectMake(nameLabel.x, jobLabel.y+jobLabel.height ,nameLabel.width, 21) text:@""];
    //动态计算设置宽度
    holidaycountLabel.width=[LZXHelper textWidthFromTextString:holidaycountLabel.text Height:21 fontSize:13]+3;
    holidaycountLabel.font=FONT_13;
    [headView addSubview:holidaycountLabel];
    
    UIButton *systemButton=nil;
    //异常考勤不需要制度按钮
    if (![_businessCode isEqualToString:@"YC0012"]) {
        //制度按钮
        systemButton=[MyControl creatButtonWithFrame:CGRectMake(holidaycountLabel.x+holidaycountLabel.width+8,holidaycountLabel.y, 50, 21) target:self sel:@selector(systemButtonClick) tag:105 image:nil title:@"制度"];
        [systemButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        systemButton.titleLabel.font=[UIFont systemFontOfSize:13];
        [headView addSubview:systemButton];
    }

    
//    if ([self.isOwn isEqualToString:@"0"]) {
        //消息按钮
    UIButton *messageButton=[MyControl creatButtonWithFrame:CGRectMake(IPHONE_WIDTH-76,30, 30, 30) target:self sel:@selector(messageButtonClick) tag:106 image:@"k_ic_xx2@2x" title:nil];
    [headView addSubview:messageButton];
//    }
    
    //汇总查询按钮
    UIButton *infoButton=[MyControl creatButtonWithFrame:CGRectMake(IPHONE_WIDTH-38,30, 30, 30) target:self sel:@selector(infoButtonClick) tag:106 image:@"k_ic_tj3@2x" title:nil];
    [headView addSubview:infoButton];
    
    //获取用户信息
    if (_taskDetailModel.dataArr.count>0) {
        TaskDetailModel *model=_taskDetailModel.dataArr[0];
        self.keywordId=model.vacateType;
        //判断是否是可编辑 可编辑则显示管控时间
        if (_viewHeight>0) {
            [self getCountdownTimeInfoRequest];
        }
        nameLabel.text=model.dealEmp?model.dealEmp:@"";
        if ([model.dealEmp isEqualToString:[LZXHelper getUserName]]) {
            messageButton.hidden=YES;
        }
        //动态计算设置宽度
        nameLabel.width=[LZXHelper textWidthFromTextString:nameLabel.text Height:21 fontSize:15]+3;
        positionLabel.frame=CGRectMake(nameLabel.x+nameLabel.width+8, 16, IPHONE_WIDTH-(nameLabel.x+nameLabel.width+8)-8, 18);
        //设置请假时长
        NSString *holidayStr=[self getVacateTypeWithBusinessCode:self.businessCode sex:self.sex];
        if ([self.businessCode isEqualToString:@"YC0012"]) {
            holidayStr=model.vacateDays?model.vacateDays:@"";
        }else{
            holidayStr=[holidayStr stringByAppendingString:[NSString stringWithFormat:@"%@天",model.vacateDays?model.vacateDays:@""]];
        }
        //转换时间格式
        NSDateFormatter *formatter=[NSDateFormatter new];
        [formatter setDateFormat:@"yyyy-MM-dd HH:mm:ss"];
        NSDate *newDate=[formatter dateFromString:model.dealTime];
        [formatter setDateFormat:@"yyyy-MM-dd HH:mm"];
        NSString *newTimeStr=[formatter stringFromDate:newDate];
        if (!([self.businessCode isEqualToString:@"GC0009"]||[self.businessCode isEqualToString:@"YC0012"]||[self.businessCode isEqualToString:@"JB0011"])) {
            //根据时间判断是不是补假
            if (![self compareOneTime:newTimeStr withAnotherTime:model.endTime]) {
                holidayStr=[holidayStr stringByAppendingString:@"[补假]"];
                holidaycountLabel.textColor=COLOR_PINK;
            }else{
                holidaycountLabel.textColor=[UIColor whiteColor];
            }
        }else{
            holidaycountLabel.textColor=[UIColor whiteColor];
        }

        if (![_businessCode isEqualToString:@"YC0012"]) {
            holidaycountLabel.text=holidayStr;
        }else{
            holidaycountLabel.text=@"异常打卡申请";
        }
        UIButton *goOut=nil;
        //动态计算设置宽度
        holidaycountLabel.width=[LZXHelper textWidthFromTextString:holidaycountLabel.text Height:21 fontSize:13]+3;
        if (systemButton) {
            systemButton.frame=CGRectMake(holidaycountLabel.x+holidaycountLabel.width+8,holidaycountLabel.y, 50, 21);
            
            if ([self.businessCode isEqualToString:@"GC0009"]) {
                //公出轨迹
                goOut=[MyControl creatButtonWithFrame:CGRectMake(systemButton.x+systemButton.width+8,holidaycountLabel.y, 70, 21) target:self sel:@selector(goOutClick) tag:106 image:nil title:@"公出轨迹"];
                [goOut setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
                goOut.titleLabel.font=[UIFont systemFontOfSize:13];
                [headView addSubview:goOut];
            }
        }
        
        if (model.empInfo&&model.empInfo.length>0) {
            //去掉前面的|
            if ([[model.empInfo substringToIndex:1]isEqualToString:@"|"]) {
                model.empInfo=[model.empInfo substringFromIndex:1];
            }
            //去掉最后面的|
            if ([[model.empInfo substringFromIndex:model.empInfo.length-1]isEqualToString:@"|"]) {
                model.empInfo =[model.empInfo substringToIndex:model.empInfo.length-1];
            }
            NSArray *infoArr=[model.empInfo componentsSeparatedByString:@"|"];
            //设置头像
            if (infoArr.count>1) {
                self.empId=infoArr[0];
                [headImageView setImageWithURL:[NSURL URLWithString:infoArr[1]] placeholderImage:[UIImage imageNamed:@"k_portrait@2x.png"]];
            }
            //设置上班的状态
            if (infoArr.count>2) {
                self.statusInfo=[infoArr[2] componentsSeparatedByString:@"&"];
                NSString *infoStr=@"";
                if (self.statusInfo.count>1) {
                    infoStr=self.statusInfo[0];
                    [statusButton setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
                }else{
                    infoStr=infoArr[2];
                }
                
                [statusButton setTitle:infoStr forState:UIControlStateNormal];
                if ([infoStr isEqualToString:@"休息中"]) {
                    [statusImageView setImage:[UIImage imageNamed:@"k_ic_ts_xxz@2x"]];
                    statusButton.userInteractionEnabled=NO;
                }else if ([infoStr isEqualToString:@"请假中"]){
                    [statusImageView setImage:[UIImage imageNamed:@"k_ic_ts_qjz@2x"]];
                    statusButton.userInteractionEnabled=YES;
                }else if ([infoStr isEqualToString:@"公出中"]){
                    [statusImageView setImage:[UIImage imageNamed:@"k_ic_ts_gcz@2x"]];
                    statusButton.userInteractionEnabled=YES;
                }else if ([infoStr isEqualToString:@"加班中"]){
                    [statusImageView setImage:[UIImage imageNamed:@"k_ic_ts_jbz@2x"]];
                    statusButton.userInteractionEnabled=YES;
                }else if ([infoStr isEqualToString:@"工作中"]){
                    [statusImageView setImage:[UIImage imageNamed:@"k_ic_ts_gzz@2x"]];
                    statusButton.userInteractionEnabled=NO;
                }else if ([infoStr isEqualToString:@"午休中"]){
                    [statusImageView setImage:[UIImage imageNamed:@"k_ic_ts_xxz@2x"]];
                    statusButton.userInteractionEnabled=NO;
                }

            }
            //项目组
            if (infoArr.count>3) {
                jobLabel.text=infoArr[3];
                //动态计算设置宽度
                jobLabel.width=[LZXHelper textWidthFromTextString:jobLabel.text Height:21 fontSize:13]+3;
            }
            //工作岗位
            if (infoArr.count>4) {
                positionLabel.text=infoArr[4];
            }
        }
    }
    
}

#pragma mark - creatTableView
- (void)creatView{

    _tableView=[[UITableView alloc]initWithFrame:CGRectMake(0, 90, IPHONE_WIDTH, IPHONE_HEIGHT-64-90-(_viewHeight>0?40:0)) style:UITableViewStylePlain];
    _tableView.backgroundColor=[UIColor clearColor];
    _tableView.delegate=self;
    _tableView.dataSource=self;
    _tableView.tag=110;
    _tableView.separatorStyle=UITableViewCellSeparatorStyleNone;
    _tableView.showsVerticalScrollIndicator=NO;
    _tableView.showsHorizontalScrollIndicator=NO;
    _tableView.bounces=NO;
    [_tableView sendSubviewToBack:_backMsgView];
    //[self.view insertSubview:_tableView belowSubview:_backMsgView];
    //[self addTableViewUpdateRefresh:_tableView BindingIdentity:@""];
    //    [self addTableViewLoadMoreData:_tableView BindingIdentity:@""];
    [self.view addSubview:_tableView];
    //    self.definesPresentationContext = YES;
    
    //下方空白的view
    UIView *footView=[[UIView alloc]initWithFrame:CGRectMake(0, 0, IPHONE_WIDTH, 20+64)];
    _tableView.tableFooterView=footView;
}

#pragma mark -审批框
- (void)creatApproveTextView{
    //批复框
    _backMsgView=[[UIView alloc]initWithFrame:CGRectMake(0, IPHONE_HEIGHT-40-64, IPHONE_WIDTH, 129)];
    _backMsgView.backgroundColor=[UIColor clearColor];
    [self.view addSubview:_backMsgView];
    
    //批复框的开关
    UIButton *openButton=[MyControl creatButtonWithFrame:CGRectMake(0,2, IPHONE_WIDTH, 36) target:self sel:@selector(openButtonClick:) tag:150 image:nil title:@""];
    //        button.layer.masksToBounds=YES;
    //        button.layer.cornerRadius=5;
    //        button.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;
    //[openButton setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    [openButton setImage:[UIImage imageNamed:@"k_ic_slide_up@2x"] forState:UIControlStateNormal];
    [openButton setImage:[UIImage imageNamed:@"k_ic_slide_down@2x"] forState:UIControlStateSelected];
    //openButton.imageEdgeInsets=UIEdgeInsetsMake(0, 10, 0, 50);
    //button.titleEdgeInsets=UIEdgeInsetsMake(10, 10, 10, 40);
    [_backMsgView addSubview:openButton];
    
    //批复框白色背景View
    UIView *backView=[[UIView alloc]initWithFrame:CGRectMake(0, 40, IPHONE_WIDTH, _backMsgView.height-40)];
    backView.backgroundColor=[UIColor whiteColor];
    [_backMsgView addSubview:backView];
    
    //批复按钮
    NSArray *titleArr=@[@"同意",@"驳回"];
    for (int i=0; i<titleArr.count; i++) {
        UIButton *button=[MyControl creatButtonWithFrame:CGRectMake(10+120*i,8, 90, 30) target:self sel:@selector(selectButton:) tag:130+i image:nil title:titleArr[i]];
//        button.layer.masksToBounds=YES;
//        button.layer.cornerRadius=5;
//        button.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;
        [button setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
        [button setImage:[UIImage imageNamed:@"k_ic_rb1@2x"] forState:UIControlStateNormal];
        [button setImage:[UIImage imageNamed:@"k_ic_rb2@2x"] forState:UIControlStateSelected];
        button.imageEdgeInsets=UIEdgeInsetsMake(0, 10, 0, 50);
        //button.titleEdgeInsets=UIEdgeInsetsMake(10, 10, 10, 40);
        if (i==0) {
            button.selected=YES;
        }
        [backView addSubview:button];
    }
    
    //消息框
    _msgTextView=[[UITextView alloc]initWithFrame:CGRectMake(8, 38, IPHONE_WIDTH-76-8, 35)];
    _msgTextView.layer.borderWidth=1;
    _msgTextView.layer.borderColor=[BACKCOLOR_GRAY CGColor];
    _msgTextView.layer.masksToBounds=YES;
    _msgTextView.layer.cornerRadius=5;
    _msgTextView.delegate=self;
    _msgTextView.font=FONT_14;
    _msgTextView.text=TEXTVIEWMESSAGE_AGREE;
    _msgTextView.textColor=[UIColor blackColor];
    [backView addSubview:_msgTextView];
    
    //发送按钮
    UIButton *sendButton=[MyControl creatButtonWithFrame:CGRectMake(_msgTextView.x+_msgTextView.width+8, _msgTextView.y, 60, _msgTextView.height) target:self sel:@selector(sendButtonClick) tag:300 image:nil title:@"提交"];
    [sendButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    sendButton.backgroundColor=COLOR_MIDBLUE;
    sendButton.layer.masksToBounds=YES;
    sendButton.layer.cornerRadius=5;
    [backView addSubview:sendButton];
}

#pragma mark -核销框
- (void)creatVerifyTextView{
    //批复框
    _backMsgView=[[UIView alloc]initWithFrame:CGRectMake(0, IPHONE_HEIGHT-40-64, IPHONE_WIDTH, 129)];
    _backMsgView.backgroundColor=[UIColor clearColor];
    [self.view addSubview:_backMsgView];
    
    //批复框的开关
    UIButton *openButton=[MyControl creatButtonWithFrame:CGRectMake(0,2, IPHONE_WIDTH, 36) target:self sel:@selector(openButtonClick:) tag:150 image:nil title:@""];
    //        button.layer.masksToBounds=YES;
    //        button.layer.cornerRadius=5;
    //        button.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;
    //[openButton setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    [openButton setImage:[UIImage imageNamed:@"k_ic_slide_up@2x"] forState:UIControlStateNormal];
    [openButton setImage:[UIImage imageNamed:@"k_ic_slide_down@2x"] forState:UIControlStateSelected];
    //openButton.imageEdgeInsets=UIEdgeInsetsMake(0, 10, 0, 50);
    //button.titleEdgeInsets=UIEdgeInsetsMake(10, 10, 10, 40);
    [_backMsgView addSubview:openButton];
    
    //批复框白色背景View
    UIView *backView=[[UIView alloc]initWithFrame:CGRectMake(0, 40, IPHONE_WIDTH, _backMsgView.height-40)];
    backView.backgroundColor=[UIColor whiteColor];
    [_backMsgView addSubview:backView];
    
    //批复按钮
    NSArray *titleArr=@[@"同意",@"驳回",@"事假考核"];
    for (int i=0; i<titleArr.count; i++) {
        UIButton *button=[MyControl creatButtonWithFrame:CGRectMake(10+(IPHONE_WIDTH/3-10)*i,8, IPHONE_WIDTH/3-10, 30) target:self sel:@selector(verifyButton:) tag:130+i image:nil title:titleArr[i]];
        //        button.layer.masksToBounds=YES;
        //        button.layer.cornerRadius=5;
        //        button.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;
        [button setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
        [button setImage:[UIImage imageNamed:@"k_ic_rb1@2x"] forState:UIControlStateNormal];
        [button setImage:[UIImage imageNamed:@"k_ic_rb2@2x"] forState:UIControlStateSelected];
        button.imageEdgeInsets=UIEdgeInsetsMake(0, 10, 0, 50);
        //button.titleEdgeInsets=UIEdgeInsetsMake(10, 10, 10, 40);
        if (i==0) {
            button.selected=YES;
        }
        [backView addSubview:button];
    }
    
    //消息框
    _msgTextView=[[UITextView alloc]initWithFrame:CGRectMake(8, 38, IPHONE_WIDTH-76-8, 35)];
    _msgTextView.layer.borderWidth=1;
    _msgTextView.layer.borderColor=[BACKCOLOR_GRAY CGColor];
    _msgTextView.layer.masksToBounds=YES;
    _msgTextView.layer.cornerRadius=5;
    _msgTextView.delegate=self;
    _msgTextView.font=FONT_14;
    _msgTextView.text=TEXTVIEWMESSAGE_AGREE;
    _msgTextView.textColor=[UIColor blackColor];
    [backView addSubview:_msgTextView];
    
    //发送按钮
    UIButton *sendButton=[MyControl creatButtonWithFrame:CGRectMake(_msgTextView.x+_msgTextView.width+8, _msgTextView.y, 60, _msgTextView.height) target:self sel:@selector(sendVerifyClick) tag:300 image:nil title:@"提交"];
    [sendButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    sendButton.backgroundColor=COLOR_MIDBLUE;
    sendButton.layer.masksToBounds=YES;
    sendButton.layer.cornerRadius=5;
    [backView addSubview:sendButton];
}

#pragma mark -编辑框
- (void)creatEditTextView{
    //批复框
    _backMsgView=[[UIView alloc]initWithFrame:CGRectMake(0, IPHONE_HEIGHT-40-64, IPHONE_WIDTH, 90)];
    _backMsgView.backgroundColor=[UIColor clearColor];
    [self.view addSubview:_backMsgView];
    
    //批复框的开关
    UIButton *openButton=[MyControl creatButtonWithFrame:CGRectMake(0,2, IPHONE_WIDTH, 36) target:self sel:@selector(openButtonClick:) tag:150 image:nil title:@""];
    //        button.layer.masksToBounds=YES;
    //        button.layer.cornerRadius=5;
    //        button.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;
    //[openButton setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    [openButton setImage:[UIImage imageNamed:@"k_ic_slide_up@2x"] forState:UIControlStateNormal];
    [openButton setImage:[UIImage imageNamed:@"k_ic_slide_down@2x"] forState:UIControlStateSelected];
    //openButton.imageEdgeInsets=UIEdgeInsetsMake(0, 10, 0, 50);
    //button.titleEdgeInsets=UIEdgeInsetsMake(10, 10, 10, 40);
    [_backMsgView addSubview:openButton];
    
    //批复框白色背景View
    UIView *backView=[[UIView alloc]initWithFrame:CGRectMake(0, 40, IPHONE_WIDTH, _backMsgView.height-50)];
    backView.backgroundColor=[UIColor whiteColor];
    [_backMsgView addSubview:backView];
    
    //编辑按钮
    UIButton *sendButton=[MyControl creatButtonWithFrame:CGRectMake(5,5,IPHONE_WIDTH-10,40) target:self sel:@selector(editButtonClick) tag:301 image:nil title:@"编辑"];
    [sendButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    sendButton.backgroundColor=COLOR_MIDBLUE;
    sendButton.layer.masksToBounds=YES;
    sendButton.layer.cornerRadius=5;
    [backView addSubview:sendButton];
}

#pragma mark -撤销框
- (void)creatCancelTextView{
    //批复框
    _backMsgView=[[UIView alloc]initWithFrame:CGRectMake(0, IPHONE_HEIGHT-40-64, IPHONE_WIDTH, 90)];
    _backMsgView.backgroundColor=[UIColor clearColor];
    [self.view addSubview:_backMsgView];
    
    //批复框的开关
    UIButton *openButton=[MyControl creatButtonWithFrame:CGRectMake(0,2, IPHONE_WIDTH, 36) target:self sel:@selector(openButtonClick:) tag:150 image:nil title:@""];
    //        button.layer.masksToBounds=YES;
    //        button.layer.cornerRadius=5;
    //        button.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;
    //[openButton setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    [openButton setImage:[UIImage imageNamed:@"k_ic_slide_up@2x"] forState:UIControlStateNormal];
    [openButton setImage:[UIImage imageNamed:@"k_ic_slide_down@2x"] forState:UIControlStateSelected];
    //openButton.imageEdgeInsets=UIEdgeInsetsMake(0, 10, 0, 50);
    //button.titleEdgeInsets=UIEdgeInsetsMake(10, 10, 10, 40);
    [_backMsgView addSubview:openButton];
    
    //批复框白色背景View
    UIView *backView=[[UIView alloc]initWithFrame:CGRectMake(0, 40, IPHONE_WIDTH, _backMsgView.height-50)];
    backView.backgroundColor=[UIColor whiteColor];
    [_backMsgView addSubview:backView];
    
    //编辑按钮
    UIButton *sendButton=[MyControl creatButtonWithFrame:CGRectMake(5,5,IPHONE_WIDTH-10,40) target:self sel:@selector(cancelButtonClick) tag:301 image:nil title:@"撤销"];
    [sendButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    sendButton.backgroundColor=COLOR_MIDBLUE;
    sendButton.layer.masksToBounds=YES;
    sendButton.layer.cornerRadius=5;
    [backView addSubview:sendButton];
}

#pragma mark -延假框
- (void)creatAddHolidayTextView{
    //批复框
    _backMsgView=[[UIView alloc]initWithFrame:CGRectMake(0, IPHONE_HEIGHT-40-64, IPHONE_WIDTH, 90)];
    _backMsgView.backgroundColor=[UIColor clearColor];
    [self.view addSubview:_backMsgView];
    
    //批复框的开关
    UIButton *openButton=[MyControl creatButtonWithFrame:CGRectMake(0,2, IPHONE_WIDTH, 36) target:self sel:@selector(openButtonClick:) tag:150 image:nil title:@""];
    //        button.layer.masksToBounds=YES;
    //        button.layer.cornerRadius=5;
    //        button.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;
    //[openButton setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    [openButton setImage:[UIImage imageNamed:@"k_ic_slide_up@2x"] forState:UIControlStateNormal];
    [openButton setImage:[UIImage imageNamed:@"k_ic_slide_down@2x"] forState:UIControlStateSelected];
    //openButton.imageEdgeInsets=UIEdgeInsetsMake(0, 10, 0, 50);
    //button.titleEdgeInsets=UIEdgeInsetsMake(10, 10, 10, 40);
    [_backMsgView addSubview:openButton];
    
    //批复框白色背景View
    UIView *backView=[[UIView alloc]initWithFrame:CGRectMake(0, 40, IPHONE_WIDTH, _backMsgView.height-50)];
    backView.backgroundColor=[UIColor whiteColor];
    [_backMsgView addSubview:backView];
    
    //编辑按钮
    UIButton *sendButton=[MyControl creatButtonWithFrame:CGRectMake(5,5,IPHONE_WIDTH-10,40) target:self sel:@selector(addHolidayButtonClick) tag:301 image:nil title:@"延假"];
    [sendButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    sendButton.backgroundColor=COLOR_MIDBLUE;
    sendButton.layer.masksToBounds=YES;
    sendButton.layer.cornerRadius=5;
    [backView addSubview:sendButton];
}

#pragma mark -汇报框
- (void)creatReportTextView{
    //批复框
    _backMsgView=[[UIView alloc]initWithFrame:CGRectMake(0, IPHONE_HEIGHT-40-64, IPHONE_WIDTH, 90)];
    _backMsgView.backgroundColor=[UIColor clearColor];
    [self.view addSubview:_backMsgView];
    
    //批复框的开关
    UIButton *openButton=[MyControl creatButtonWithFrame:CGRectMake(0,2, IPHONE_WIDTH, 36) target:self sel:@selector(openButtonClick:) tag:150 image:nil title:@""];
    //        button.layer.masksToBounds=YES;
    //        button.layer.cornerRadius=5;
    //        button.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;
    //[openButton setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    [openButton setImage:[UIImage imageNamed:@"k_ic_slide_up@2x"] forState:UIControlStateNormal];
    [openButton setImage:[UIImage imageNamed:@"k_ic_slide_down@2x"] forState:UIControlStateSelected];
    //openButton.imageEdgeInsets=UIEdgeInsetsMake(0, 10, 0, 50);
    //button.titleEdgeInsets=UIEdgeInsetsMake(10, 10, 10, 40);
    [_backMsgView addSubview:openButton];
    
    //批复框白色背景View
    UIView *backView=[[UIView alloc]initWithFrame:CGRectMake(0, 40, IPHONE_WIDTH, _backMsgView.height-50)];
    backView.backgroundColor=[UIColor whiteColor];
    [_backMsgView addSubview:backView];
    
    //编辑按钮
    UIButton *sendButton=[MyControl creatButtonWithFrame:CGRectMake(5,5,IPHONE_WIDTH-10,40) target:self sel:@selector(reportButtonClick) tag:301 image:nil title:@"汇报"];
    [sendButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    sendButton.backgroundColor=COLOR_MIDBLUE;
    sendButton.layer.masksToBounds=YES;
    sendButton.layer.cornerRadius=5;
    [backView addSubview:sendButton];
}

#pragma mark -销假框
- (void)creatEndHolidayTextView{
    //批复框
    _backMsgView=[[UIView alloc]initWithFrame:CGRectMake(0, IPHONE_HEIGHT-40-64, IPHONE_WIDTH, 90)];
    _backMsgView.backgroundColor=[UIColor clearColor];
    [self.view addSubview:_backMsgView];
    
    //批复框的开关
    UIButton *openButton=[MyControl creatButtonWithFrame:CGRectMake(0,2, IPHONE_WIDTH, 36) target:self sel:@selector(openButtonClick:) tag:150 image:nil title:@""];
    //        button.layer.masksToBounds=YES;
    //        button.layer.cornerRadius=5;
    //        button.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;
    //[openButton setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    [openButton setImage:[UIImage imageNamed:@"k_ic_slide_up@2x"] forState:UIControlStateNormal];
    [openButton setImage:[UIImage imageNamed:@"k_ic_slide_down@2x"] forState:UIControlStateSelected];
    //openButton.imageEdgeInsets=UIEdgeInsetsMake(0, 10, 0, 50);
    //button.titleEdgeInsets=UIEdgeInsetsMake(10, 10, 10, 40);
    [_backMsgView addSubview:openButton];
    
    //批复框白色背景View
    UIView *backView=[[UIView alloc]initWithFrame:CGRectMake(0, 40, IPHONE_WIDTH, _backMsgView.height-50)];
    backView.backgroundColor=[UIColor whiteColor];
    [_backMsgView addSubview:backView];
    
    //编辑按钮
    UIButton *sendButton=[MyControl creatButtonWithFrame:CGRectMake(5,5,IPHONE_WIDTH-10,40) target:self sel:@selector(endHolidayButtonClick) tag:301 image:nil title:@"销假"];
    [sendButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    sendButton.backgroundColor=COLOR_MIDBLUE;
    sendButton.layer.masksToBounds=YES;
    sendButton.layer.cornerRadius=5;
    [backView addSubview:sendButton];
}


#pragma mark - 右边导航栏
- (void)setRightNavigation:(NSString *)title{
    //
    if (self.navigationItem.rightBarButtonItem) {
        self.navigationItem.rightBarButtonItem.title=title;
    }else{
        _timeLabel=[MyControl creatLabelWithFrame:CGRectMake(0, 0, 60, 44) text:@""];
        //_timeLabel.backgroundColor=[UIColor redColor];
        _timeLabel.textAlignment=NSTextAlignmentRight;
        _timeLabel.textColor=[UIColor whiteColor];
        UIBarButtonItem *item=[[UIBarButtonItem alloc]initWithCustomView:_timeLabel];
        [item setTintColor:[UIColor whiteColor]];
        self.navigationItem.rightBarButtonItem=item;
    }
    
    //    [self.navigationItem.rightBarButtonItem setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:[UIFont boldSystemFontOfSize:13], NSFontAttributeName, [UIColor whiteColor], NSFontAttributeName, nil] forState:UIControlStateNormal];
}
#pragma mark -键盘通知
- (void)keyboardWillShow:(NSNotification *)aNotification
{
    NSDictionary *userInfo = [aNotification userInfo];
    NSValue *aValue = [userInfo objectForKey:UIKeyboardFrameEndUserInfoKey];
    CGRect keyboardRect = [aValue CGRectValue];
    CGFloat height = keyboardRect.size.height;
    [UIView animateWithDuration:0.3 animations:^{
        _backMsgView.y=IPHONE_HEIGHT-_viewHeight-height-64;
        _tableView.height=IPHONE_HEIGHT-64-90-40-height-_viewHeight;
    }];
//    _tapGesture = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(tapGestureClick)];
//    
//    [_tableView addGestureRecognizer:_tapGesture];
//    _tableView.y-=height;
    [self addTapGestureRecognizerWithView:_tableView];
    // CGFloat width = keyboardRect.size.width;
    
}

//#pragma mark -滚动视图delegate
//
//- (void)scrollViewDidScroll:(UIScrollView *)scrollView{
//    if (_msgTextView.superview iski) {
//        <#statements#>
//    }
//}

//当键退出时调用
- (void)keyboardWillHide:(NSNotification *)aNotification
{
    //    //获取键盘高度
    //    NSDictionary *userInfo = [aNotification userInfo];
    //    NSValue *aValue = [userInfo objectForKey:UIKeyboardFrameEndUserInfoKey];
    //    CGRect keyboardRect = [aValue CGRectValue];
    //    CGFloat height = keyboardRect.size.height;
    
    [UIView animateWithDuration:0.3 animations:^{
        _backMsgView.y=IPHONE_HEIGHT-_viewHeight-64;
        _tableView.height=IPHONE_HEIGHT-64-90-40-_viewHeight;
    }];
    [self removeTapGestureRecognizerWithView:_tableView];
    
}
#pragma mark - 核销提交按钮
- (void)sendVerifyClick{
    NSString *state=@"";
    UIButton *agree=(UIButton *)[_backMsgView viewWithTag:130];
    UIButton *verify=(UIButton *)[_backMsgView viewWithTag:132];
    if (agree.selected) {
        state=@"1";
    }else if(verify.selected){
        state=@"2";
        if (_msgTextView.text.length==0) {
            [LZXHelper postMessageWithText:@"核销意见不能为空!" View:self.view];
            return;
        }
    }else{
        state=@"0";
        if (_msgTextView.text.length==0) {
            [LZXHelper postMessageWithText:@"审批意见不能为空!" View:self.view];
            return;
        }
    }
    [self.view endEditing:YES];
    [LZXHelper postAlertViewControllerWithTitle:@"确认是否核销?" message:nil cancelButtonTitle:@"取消" otherButtonTitle:@"确认" cancelEvent:^{
        
    } otherEvent:^{
            [self postVerifyEliminateInfoRequestWithState:state];
    } viewController:self];
}

#pragma mark -公出轨迹
- (void)goOutClick{
    PersonGoOutDetailViewController *goout=[PersonGoOutDetailViewController new];
    goout.vacateBillId=self.vacateBillId;

    if (_taskDetailModel.dataArr.count>0) {
        TaskDetailModel *model=[_taskDetailModel.dataArr firstObject];
        goout.address=model.content2;
        goout.time=[NSString stringWithFormat:@"公出时间：%@ 至 %@",model.startTime,model.endTime];
    }
    [self.navigationController pushViewController:goout animated:YES];
}

#pragma mark - 审批提交按钮
- (void)sendButtonClick{
//    if ([_msgTextView.text isEqualToString:;]||_msgTextView.text.length==0) {
//        [LZXHelper postMessageWithText:@"请输入发送内容!" View:IPHONEWINDOW];
//        return;
//    }
    //非空判断
//    if ([LZXHelper isEmpty:_msgTextView.text]) {
//        [LZXHelper postMessageWithText:@"发送内容不能为空!" View:IPHONEWINDOW];
//        return;
//    }
    NSString *state=@"";
    UIButton *agree=(UIButton *)[_backMsgView viewWithTag:130];
    if (agree.selected) {
        state=@"1";
    }else{
        state=@"0";
        if (_msgTextView.text.length==0) {
            [LZXHelper postMessageWithText:@"审批意见不能为空!" View:self.view];
            return;
        }
    }
    [self.view endEditing:YES];
    [LZXHelper postAlertViewControllerWithTitle:@"确定要提交审批?" message:nil cancelButtonTitle:@"取消" otherButtonTitle:@"确认" cancelEvent:^{
        
    } otherEvent:^{
        //公出,请假，异常审核提交
        if ([self.businessCode isEqualToString:@"GC0009"]||[self.businessCode isEqualToString:@"YC0012"]||[self.businessCode isEqualToString:@"JB0011"]) {
            if (([self.dealState isEqualToString:@"1"]||[self.dealState isEqualToString:@"0"])&&[self.isOwn isEqualToString:@"0"]) {
                [self postApproveNewFlowInfoRequestWithState:state];
            }else{
                [self postSHInfoRequestWithState:state];
            }
        }else{
        //请假审核提交
            if ([self.dealState isEqualToString:@"1"]&&[self.isOwn isEqualToString:@"0"]) {
                [self postApproveInfoRequestWithState:state];
            }
        }
    } viewController:self];
}

#pragma mark -textViewDelegate
- (BOOL)textViewShouldBeginEditing:(UITextView *)textView{
//    if ([textView.text isEqualToString:TEXTVIEWMESSAGE]) {
//        textView.textColor=[UIColor blackColor];
//        textView.text=@"";
//    }
    return YES;
}

- (BOOL)textViewShouldEndEditing:(UITextView *)textView{
//    if (textView.text.length==0) {
//        textView.textColor=[UIColor lightGrayColor];
//        textView.text=TEXTVIEWMESSAGE;
//    }
    return YES;
}

#pragma mark -scrollViewDelagate
- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView{
    [self.view endEditing:YES];
    UIButton *button=(UIButton *)[_backMsgView viewWithTag:150];
    if (scrollView.contentOffset.y > _oldOffset) {//如果当前位移大于缓存位移，说明scrollView向上滑动
        [UIView animateWithDuration:0.3 animations:^{
            _backMsgView.y=IPHONE_HEIGHT-_viewHeight-64;
            _tableView.height=IPHONE_HEIGHT-64-90-_viewHeight;
        }];
        button.selected=YES;
    }else{
        [UIView animateWithDuration:0.3 animations:^{
            //如果有高度 就是可编辑页面
            _backMsgView.y=IPHONE_HEIGHT-(_viewHeight>0?40:0)-64;
            _tableView.height=IPHONE_HEIGHT-64-90-(_viewHeight>0?40:0);
        }];
        button.selected=NO;
    }
    _oldOffset = scrollView.contentOffset.y;//将当前位移变成缓存位移
}

#pragma mark -消息查看
- (void)messageButtonClick{
    [self.view endEditing:YES];
    //获取用户信息
    if (_taskDetailModel.dataArr.count>0) {
        TaskDetailModel *model=_taskDetailModel.dataArr[0];
        //去掉前面的|
        if ([[model.empInfo substringToIndex:1]isEqualToString:@"|"]) {
            model.empInfo=[model.empInfo substringFromIndex:1];
        }
        //去掉最后面的|
        if ([[model.empInfo substringFromIndex:model.empInfo.length-1]isEqualToString:@"|"]) {
            model.empInfo =[model.empInfo substringToIndex:model.empInfo.length-1];
        }
        NSArray *infoArr=[model.empInfo componentsSeparatedByString:@"|"];
        
        PersonMessageViewController *person=[PersonMessageViewController new];
        person.receEmpName=model.dealEmp;
        if (infoArr.count>0) {
            person.receEmpId=[NSNumber numberWithInteger:[infoArr[0] integerValue]];
        }
        [self.navigationController pushViewController:person animated:YES];
    }
}

#pragma mark -汇总查询按钮点击
- (void)infoButtonClick{
    [self.view endEditing:YES];
    PersonInfoDetailViewController *person=[PersonInfoDetailViewController new];
    person.empIds=self.empId;
    
    [self.navigationController pushViewController:person animated:YES];
}

#pragma mark -上班状态按钮点击
- (void)personStatusClick{
    
    //判断是不是当前的单号
    if (self.statusInfo.count>4) {
        if ([self.statusInfo[4] isEqualToString:self.vacateBillId]||[self.statusInfo[5] isEqualToString:self.businessCode]) {
            [LZXHelper postMessageWithText:@"已经是当前流程!" View:self.view];
            return;
        }
    }
    NSString *infoStr=@"";
    for (int i=1; i<self.statusInfo.count; i++) {
        infoStr=[infoStr stringByAppendingString:[NSString stringWithFormat:@"%@\n",self.statusInfo[i]]];
    }
    PromptView *promptView=[[PromptView alloc]initWithFrame:CGRectMake(0, 0, IPHONE_WIDTH, IPHONE_HEIGHT) title:@"" message:infoStr prompt:nil isHidePrompt:YES submitTitle:@"确定"];
    promptView.submitButton.backgroundColor=[UIColor orangeColor];
    [[[UIApplication sharedApplication].delegate window]addSubview:promptView];
}

#pragma mark -批复框按钮点击
- (void)openButtonClick:(UIButton *)button{
    [self.view endEditing:YES];
    button.selected=!button.selected;
    if (button.selected) {
        //弹出批复框
        [UIView animateWithDuration:0.3 animations:^{
            _backMsgView.y=IPHONE_HEIGHT-_viewHeight-64;
            _tableView.height=IPHONE_HEIGHT-64-90-_viewHeight;
        }];
    }else{
        [UIView animateWithDuration:0.3 animations:^{
            //如果有高度 就是可编辑页面
            _backMsgView.y=IPHONE_HEIGHT-(_viewHeight>0?40:0)-64;
            _tableView.height=IPHONE_HEIGHT-64-90-(_viewHeight>0?40:0);
        }];
    }
}

#pragma mark -销假点击
- (void)endHolidayButtonClick{
    //销假申请页面
    EndHolidayViewController *holiday=[EndHolidayViewController new];
    holiday.beginStr=self.beginStr;
    holiday.endStr=self.endStr;
    holiday.businessCode=self.businessCode;
    if (_taskDetailModel.dataArr.count>0) {
        TaskDetailModel *model=_taskDetailModel.dataArr[0];
        holiday.infoId=model.infoId;
        holiday.vacateBillId=model.vacateBillId;
        holiday.keywordId=model.vacateType;
    }
    holiday.navaTitle=@"销假申请";
    [self.navigationController pushViewController:holiday animated:YES];
}

#pragma mark -延假点击
- (void)addHolidayButtonClick{
    
}

#pragma mark -编辑按钮点击
- (void)editButtonClick{
    [self.view endEditing:YES];
    if (_taskDetailModel.dataArr.count>0) {
        TaskDetailModel *model=_taskDetailModel.dataArr[0];
        DutyParentsViewController *off=nil;
        //病假
        if ([self.businessCode isEqualToString:@"BJ0001"]) {
            off=[SickDetailViewController new];
        //事假
        }else if ([self.businessCode isEqualToString:@"SJ0002"]){
            off=[PersonalDetailViewController new];
        //年假
        }else if ([self.businessCode isEqualToString:@"NJ0003"]){
            off=[OffDetailViewController new];
        //产假护理假
        }else if ([self.businessCode isEqualToString:@"CJ0004"]){
            off=[MaternityDetailViewController new];
            //婚假
        }else if ([self.businessCode isEqualToString:@"HJ0005"]){
            off=[MarriageDetailViewController new];

            //丧假
        }else if ([self.businessCode isEqualToString:@"SJ0006"]){
            off=[FuneralDetailViewController new];

            //探亲
        }else if ([self.businessCode isEqualToString:@"TQ0007"]){
            off=[FamilyLeaveDetailViewController new];
            //工伤
        }else if ([self.businessCode isEqualToString:@"GS0008"]){
            off=[InjuryDetailViewController new];
            //调休
        }else if ([self.businessCode isEqualToString:@"TX0010"]){
            off=[OffDetailViewController new];
            //公出
        }else if ([self.businessCode isEqualToString:@"GC0009"]){
            off=[GoOutApplyViewController new];
            //异常
        }else if ([self.businessCode isEqualToString:@"YC0012"]){
            off=[SignInAbnormalViewController new];
            //off=[AbnormalResonViewController new];
            //加班
        }else if ([self.businessCode isEqualToString:@"JB0011"]){
            off=[DutyOvertimeViewController new];
            //考勤
        }
//        else if ([self.businessCode isEqualToString:@"KQ0013"]){
//            off=[OffDetailViewController new];
//        }
        off.navaTitle=[self getVacateTypeWithBusinessCode:self.businessCode sex:self.sex];
        off.businessCode=self.businessCode;
        off.dutyType=0;
        off.infoId=model.infoId;
        off.keywordId=model.vacateType;
//        off.beginStr=model.startTime;
//        off.endStr=model.endTime;
        off.vacateBillId=model.vacateBillId;
        [self.navigationController pushViewController:off animated:YES];
        
    }
}

#pragma mark -撤销按钮点击
- (void)cancelButtonClick{
    [LZXHelper postAlertViewControllerWithTitle:@"确认撤销吗?" message:nil cancelButtonTitle:@"取消" otherButtonTitle:@"确认" cancelEvent:^{
        
    } otherEvent:^{
        if ([self.businessCode isEqualToString:@"GC0009"]||[self.businessCode isEqualToString:@"YC0012"]||[self.businessCode isEqualToString:@"JB0011"]) {
            
        }else{
            //撤销请假
            [self postDeleteVacateBillRequest];
        }
    } viewController:self];
}

#pragma mark -公出汇报点击
- (void)reportButtonClick{
    if (_taskDetailModel.dataArr.count>0) {
        TaskDetailModel *model=_taskDetailModel.dataArr[0];
        DutyGoBackViewController *goout=[DutyGoBackViewController new];
        goout.navaTitle=@"公出汇报";
        goout.businessCode=self.businessCode;
        goout.dutyType=0;
        goout.keywordId=model.vacateType;
        goout.infoId=model.infoId;
//        goout.beginStr=model.startTime;
//        goout.endStr=model.endTime;
        goout.vacateBillId=model.vacateBillId;
        [self.navigationController pushViewController:goout animated:YES];
    }
}

#pragma mark -核销按钮点击
- (void)verifyButton:(UIButton *)button{
    [self.view endEditing:YES];
    UIButton *agree=(UIButton *)[_backMsgView viewWithTag:130];
    UIButton *disAgree=(UIButton *)[_backMsgView viewWithTag:131];
    UIButton *verify=(UIButton *)[_backMsgView viewWithTag:132];
    //判断点击的按钮 改变默认的输入文字
    if (button==agree) {
        agree.selected=YES;
        disAgree.selected=NO;
        verify.selected=NO;
        _msgTextView.text=TEXTVIEWMESSAGE_AGREE;
    }else if(button==disAgree){
        agree.selected=NO;
        disAgree.selected=YES;;
        verify.selected=NO;
        _msgTextView.text=TEXTVIEWMESSAGE_DISAGREE;
    }else{
        agree.selected=NO;
        disAgree.selected=NO;
        verify.selected=YES;
        _msgTextView.text=TEXTVIEWMESSAGE_VERIFY;
    }
}

#pragma mark -批复按钮点击
- (void)selectButton:(UIButton *)button{
    [self.view endEditing:YES];
    UIButton *agree=(UIButton *)[_backMsgView viewWithTag:130];
    UIButton *disAgree=(UIButton *)[_backMsgView viewWithTag:131];
    //判断点击的按钮 改变默认的输入文字
    if (button==agree) {
        agree.selected=YES;
        disAgree.selected=NO;
        _msgTextView.text=TEXTVIEWMESSAGE_AGREE;
    }else{
        agree.selected=NO;
        disAgree.selected=YES;;
        _msgTextView.text=TEXTVIEWMESSAGE_DISAGREE;
    }
}

#pragma mark - 折叠式cell点击
- (void)signButtonClick:(UIButton *)button{
    [self.view endEditing:YES];
    //点击之后刷新列表
    TaskDetailModel *selectModel=_taskDetailModel.dataArr[button.tag-1000];
    selectModel.isOpen=!selectModel.isOpen;
    //是否显示委托人

//    for (int i=0; i<_taskDetailModel.dataArr.count; i++) {
//        TaskDetailModel *model=_taskDetailModel.dataArr[i];
//        if (i==button.tag-1000) {
//            model.isOpen=!model.isOpen;
//        }else{
//            model.isOpen=NO;
//        }
//    }
//    [_tableView reloadData];
    //    [_tableView reloadSections:[[NSIndexSet alloc]initWithIndex:0] withRowAnimation:UITableViewRowAnimationFade];
    [_tableView reloadRowsAtIndexPaths:[NSArray arrayWithObject:[NSIndexPath indexPathForRow:button.tag-1000 inSection:0]] withRowAnimation:UITableViewRowAnimationFade];
}

#pragma mark -照片查看

- (void)photoClick:(UIButton *)button{
    //获取对应的model
    TaskDetailModel *taskModel=self.photoModelArr[[self.photoArr indexOfObject:button]];
    //图片查看
    ImageDetailViewController *imageViewController=[ImageDetailViewController new];
    imageViewController.imageUrl=taskModel.eliminateApproveUrl;
    [self.navigationController pushViewController:imageViewController animated:YES];
}

#pragma mark -制度按钮点击
- (void)systemButtonClick{
    [self.view endEditing:YES];
    if (!_institutionListModel) {
        return;
    }
    NSString *message=@"";
    //拼接字符串
    for (int i=0; i<_institutionListModel.dataArr.count; i++) {
        InstitutionListModel *model=_institutionListModel.dataArr[i];
        NSString *msg=[NSString stringWithFormat:@"%d . %@\n",i+1,model.institution];
        message=[message stringByAppendingString:msg];
    }
    //弹出提示框
    _promptView=[[PromptView alloc]initWithFrame:CGRectMake(0, 0, IPHONE_WIDTH, IPHONE_HEIGHT) title:[NSString stringWithFormat:@"%@制度",[self getVacateTypeWithBusinessCode:self.businessCode sex:@"0"]] message:message prompt:nil isHidePrompt:YES submitTitle:@"知道了"];
    [[[UIApplication sharedApplication].delegate window]addSubview:_promptView];
}

#pragma mark -定时器刷新函数
- (void)timerFunc

{
    if (_second>0) {
        _second--;
    }else{
        _minute--;
        _second=59;
    }
    if (_minute<=0) {
        _timeLabel.textColor=[UIColor redColor];
    }
//    _timeLabel.text=[NSString stringWithFormat:@"%02ld:%02ld",_minute,_second];
    //[self setRightNavigation:];
    if (_minute==0&&_second==0) {
        [self theTimeOut];
        [_timer setFireDate:[NSDate distantFuture]];
    }
}

#pragma mark -计时器函数
- (void)theTimeOut{
    //NSLog(@"时间到了!");
    TaskDetailViewController *mySelf=self;
    [LZXHelper postAlertViewControllerWithTitle:@"已超出时间" message:@"请点击'关闭'退出当前页面" cancelButtonTitle:nil otherButtonTitle:@"关闭" cancelEvent:^{
        
    } otherEvent:^{
        if ([_timer isValid]) {
            [_timer invalidate];
            _timer=nil;
        }
        [mySelf.navigationController popViewControllerAnimated:YES];
    } viewController:self];
}

#pragma mark - TableViewDelagate

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {

    return _taskDetailModel.dataArr.count;
    //return _newsListModel.dataArr.count;
}


- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    //复用问题比较多 所以这里暂不用复用  后期需要完善
    NSString *cellID=[NSString stringWithFormat:@"TaskDetailTableViewCell%ld",indexPath.row];
    TaskDetailTableViewCell *cell=[tableView dequeueReusableCellWithIdentifier:cellID];
    if (!cell) {
        cell=[[TaskDetailTableViewCell alloc]initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:cellID];
        cell.selectionStyle=UITableViewCellSelectionStyleNone;
        //        UILabel *line=[[UILabel alloc]initWithFrame:CGRectMake(0, 77, IPHONE_WIDTH, 1)];
        //        line.backgroundColor=BACKCOLOR_GRAY;
        //        [cell.contentView addSubview:line];
        //cell.backgroundColor=[UIColor clearColor];
        [cell.openButton addTarget:self action:@selector(signButtonClick:) forControlEvents:UIControlEventTouchUpInside];
    }
    cell.openButton.tag=1000+indexPath.row;
    //获取model
    TaskDetailModel *model=_taskDetailModel.dataArr[indexPath.row];
    cell.openButton.selected=model.isOpen;
    if (cell.openButton.selected) {
        cell.lineLabel.height=[self.heightArr[indexPath.row] floatValue];
    }else{
        //如果高度需要折叠 则折叠cell
        if ([self.heightArr[indexPath.row] floatValue]>108){
            cell.lineLabel.height=108;
        }else{
            cell.lineLabel.height=[self.heightArr[indexPath.row] floatValue];
        }
    }
    //if (indexPath.row==0) {
        //填充cell
        [self setTaskDetailCellWithModel:model cell:cell indexPath:indexPath];
    //}
    //处理时间
    cell.timeLabel.text=model.dealTime;
    //判断当前所在流程
    if ([model.presentState isEqualToString:@"1"]) {
        [cell.stateImageView setImage:[UIImage imageNamed:@"k_dian_1@2x"]];
        cell.signImageView.hidden=YES;
        cell.nameLabel.textColor=[UIColor blackColor];
        cell.holidayTypeLabel.hidden=NO;;
    }else if ([model.presentState isEqualToString:@"0"]){
        [cell.stateImageView setImage:[UIImage imageNamed:@"k_dian_2@2x"]];
        cell.signImageView.hidden=NO;
        cell.nameLabel.textColor=[UIColor blackColor];
        cell.holidayTypeLabel.hidden=NO;;
    }else{
        [cell.stateImageView setImage:[UIImage imageNamed:@"k_dian_3@2x"]];
        cell.signImageView.hidden=YES;
        cell.nameLabel.textColor=[UIColor lightGrayColor];
        cell.holidayTypeLabel.hidden=YES;;
    }
    return cell;

}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
//    CGFloat height=[self.heightArr[indexPath.row] floatValue];
    TaskDetailModel *model=_taskDetailModel.dataArr[indexPath.row];
    //如果是展开
    if (model.isOpen) {
        return [self.heightArr[indexPath.row] floatValue];
    }else{
        //如果高度需要折叠 则折叠cell
        if ([self.heightArr[indexPath.row] floatValue]>108){
            return 108;
        }else{
            return [self.heightArr[indexPath.row] floatValue];
        }
    }
    //计算内容的宽和高
//    PersonMessageModel *model=_model.dataArr[indexPath.row];
//    CGFloat messageHeight=[LZXHelper textHeightFromTextString:model.msgContent?model.msgContent:@"" width:MESSAGE_WIDTH fontSize:13]+5;
    //    if (messageHeight+44>72) {
//    return messageHeight+44;
    //    }else{
    //        return 72;
    //    }
    return 166;
}


#pragma mark -设置cell
- (void)setTaskDetailCellWithModel:(TaskDetailModel *)model cell:(TaskDetailTableViewCell *)cell indexPath:(NSIndexPath *)indexPath{
    //如果有计划完成时间则显示
    cell.holidayTypeLabel.text=[NSString stringWithFormat:@"[%@]",model.dealDesc];
    cell.holidayTypeLabel.textColor=[UIColor lightGrayColor];
    if (model.planEndtime.length>0) {
        cell.planEndTimeLabel.text=model.planEndtime;
        cell.planEndTimeLabel.hidden=NO;
        cell.planEndTimeSignLabel.hidden=NO;

    }else{
        cell.planEndTimeLabel.hidden=YES;
        cell.planEndTimeSignLabel.hidden=YES;
    }
    //根据时间判断是不是超时
    if (model.timeoutLength.integerValue<0) {
        NSString *timeStr=@"";
        float time=(model.timeoutLength.floatValue*-1)*60;
        //计算超时时间
        if (time/3600<24&&(time/3600)>=1) {
            timeStr= [NSString stringWithFormat:@"%.1f小时",time/3600];
        }else if(time/3600<1){
            timeStr= [NSString stringWithFormat:@"%.1f分钟",time/60];
        }else{
            timeStr= [NSString stringWithFormat:@"%.1f天",time/(3600*24)];
        }
        cell.holidayTypeLabel.text=[NSString stringWithFormat:@"[%@超时%@]",model.dealDesc,timeStr];
        cell.holidayTypeLabel.textColor=COLOR_PINK;
        //超时则在上面
        cell.planEndTimeLabel.frame=CGRectMake(cell.lineLabel.x+cell.lineLabel.width+15, 8, IPHONE_WIDTH-(cell.lineLabel.x+cell.lineLabel.width+15)-8, 20);
        cell.planEndTimeSignLabel.frame=CGRectMake(cell.timeLabel.x+cell.timeLabel.width, 18, 16, 2);
        cell.beginTimeLabel.y=cell.nameLabel.y+cell.nameLabel.height+5;
    }else{
        cell.holidayTypeLabel.text=[NSString stringWithFormat:@"[%@]",model.dealDesc];
        cell.holidayTypeLabel.textColor=[UIColor lightGrayColor];
        if (model.planEndtime.length>0) {
            //当没有超时时时间在下面
            cell.planEndTimeLabel.frame=CGRectMake(cell.lineLabel.x+cell.lineLabel.width+15, cell.nameLabel.y+cell.nameLabel.height, IPHONE_WIDTH-(cell.lineLabel.x+cell.lineLabel.width+15)-8, 20);
            cell.planEndTimeSignLabel.frame=CGRectMake(cell.timeLabel.x+cell.timeLabel.width, 52, 16, 2);
            cell.beginTimeLabel.y=cell.nameLabel.y+cell.nameLabel.height+5+20;
        }
    }
    
    cell.nameLabel.text=model.dealEmp?model.dealEmp:@"";
    //动态计算设置宽度
    cell.nameLabel.width=[LZXHelper textWidthFromTextString:cell.nameLabel.text Height:21 fontSize:14]+3;
    cell.holidayTypeLabel.frame=CGRectMake(cell.nameLabel.x+cell.nameLabel.width, cell.nameLabel.y+2, IPHONE_WIDTH-(cell.nameLabel.x+cell.nameLabel.width)-60-8, 13);
    //填充内容
    cell.reasonLabel.text=[NSString stringWithFormat:@"内容：%@",model.cause?model.cause:@""];
    cell.businessCountLabel.text=[NSString stringWithFormat:@"编号：%@",model.vacateBillId?model.vacateBillId:@""];
    NSString *holidayStr=@"";
    if ([self.businessCode isEqualToString:@"GC0009"]) {
        holidayStr=@"公出天数";
    }else if ([self.businessCode isEqualToString:@"TX0010"]){
        holidayStr=@"调休天数";
    }else if([self.businessCode isEqualToString:@"JB0011"]){
        holidayStr=@"加班天数";
    }else{
        holidayStr=@"请假天数";
    }
    cell.holidayCountLabel.text=[NSString stringWithFormat:@"%@：%@天",holidayStr,model.vacateDays?model.vacateDays:@""];
    cell.yearHolidayLabel.text=[NSString stringWithFormat:@"年假冲抵：%@天",model.yearsCounteract?model.yearsCounteract:@""];
    //动态计算高度
    CGFloat reasonHeight=[LZXHelper textHeightFromTextString:cell.reasonLabel.text width:cell.reasonLabel.width fontSize:12]+3;
    if (reasonHeight>20) {
        cell.reasonLabel.height=reasonHeight;
    }else{
        cell.reasonLabel.height=20;
    }
    //根据有没有内容来计算高度 请假的时间字段不一样所以也要判断
    if (model.startTime.length>0||model.eliminateStartTime.length>0) {
        if (model.startTime.length>0) {
            if ([self.businessCode isEqualToString:@"YC0012"]) {
                cell.beginTimeLabel.text=model.startTime?model.startTime:@"";
            }else{
                cell.beginTimeLabel.text=[NSString stringWithFormat:@"开始时间：%@",model.startTime?model.startTime:@""];
            }
        }else{
            if ([self.businessCode isEqualToString:@"YC0012"]) {
                cell.beginTimeLabel.text=model.eliminateStartTime?model.eliminateStartTime:@"";
            }else{
                cell.beginTimeLabel.text=[NSString stringWithFormat:@"开始时间：%@",model.eliminateStartTime?model.eliminateStartTime:@""];
            }

        }
        cell.beginTimeLabel.height=20;
        cell.beginTimeLabel.hidden=NO;
    }else{
        cell.beginTimeLabel.height=0;
        cell.beginTimeLabel.hidden=YES;
    }
    
    //调整布局
    cell.endTimeLabel.y=cell.beginTimeLabel.y+cell.beginTimeLabel.height;
    
    if (model.endTime.length>0||model.eliminateEndTime.length>0) {
        if (model.endTime.length>0) {
            cell.endTimeLabel.text=[NSString stringWithFormat:@"结束时间：%@",model.endTime?model.endTime:@""];
        }else{
            cell.endTimeLabel.text=[NSString stringWithFormat:@"结束时间：%@",model.eliminateEndTime?model.eliminateEndTime:@""];
        }
        cell.endTimeLabel.height=20;
        cell.endTimeLabel.hidden=NO;
    }else{
        cell.endTimeLabel.height=0;
        cell.endTimeLabel.hidden=YES;
    }
    
    //调整布局
    cell.reasonLabel.y=cell.endTimeLabel.y+cell.endTimeLabel.height;
    if (model.cause.length>0) {
        cell.reasonLabel.height=20;
        cell.reasonLabel.hidden=NO;
    }else{
        cell.reasonLabel.height=0;
        cell.reasonLabel.hidden=YES;
    }
    
    //调整布局
    cell.businessCountLabel.y=cell.reasonLabel.y+cell.reasonLabel.height;
    if (model.vacateBillId.length>0) {
        cell.businessCountLabel.height=20;
        cell.businessCountLabel.hidden=NO;
        //根据是否展开判断需不需要隐藏
        if (!model.isOpen) {
            if (cell.businessCountLabel.y>=108) {
                cell.businessCountLabel.hidden=YES;
            }else{
                cell.businessCountLabel.hidden=NO;
            }
        }
    }else{
        cell.businessCountLabel.height=0;
        cell.businessCountLabel.hidden=YES;
    }
    
    cell.holidayCountLabel.y=cell.businessCountLabel.y+cell.businessCountLabel.height;
    if (model.vacateDays.length>0) {
        cell.holidayCountLabel.height=20;
        cell.holidayCountLabel.hidden=NO;
        //根据是否展开判断需不需要隐藏
        if (!model.isOpen) {
            if (cell.holidayCountLabel.y>=108) {
                cell.holidayCountLabel.hidden=YES;
            }else{
                cell.holidayCountLabel.hidden=NO;
            }
        }
    }else{
        cell.holidayCountLabel.height=0;
        cell.holidayCountLabel.hidden=YES;
    }
    
    
    //调整布局
    cell.yearHolidayLabel.y=cell.holidayCountLabel.y+cell.holidayCountLabel.height;
    if (model.yearsCounteract.length>0) {
        cell.yearHolidayLabel.height=20;
        cell.yearHolidayLabel.hidden=NO;
                //根据是否展开判断需不需要隐藏
        if (!model.isOpen) {
            if (cell.yearHolidayLabel.y>=108) {
                cell.yearHolidayLabel.hidden=YES;
            }else{
                cell.yearHolidayLabel.hidden=NO;
            }
        }
    }else{
        cell.yearHolidayLabel.height=0;
        cell.yearHolidayLabel.hidden=YES;
    }
    // 0：申请；1：待审批，2：申请驳回；3：待销假；4：核销驳回；5:待核销，6：核销成功
    if ([model.dealState isEqualToString:@"0"] || [model.dealState isEqualToString:@"2"]
        || [model.dealState isEqualToString:@"4"]) {
        // 显示展开按钮
        cell.openButton.hidden=NO;
    } else if ([model.dealState isEqualToString:@"3"]) {
        if ([self.businessCode isEqualToString:@"YC0012"] || [self.businessCode isEqualToString:@"JB0011"]) {
            // 隐藏展开按钮
            cell.openButton.hidden=YES;
        } else {
            // 显示展开按钮
           cell.openButton.hidden=NO;;
        }
    } else {
        // 隐藏展开按钮
        cell.openButton.hidden=YES;
    }
    
    //根绝内容高度判断是否需要显示折叠按钮
//    if ([self.heightArr[indexPath.row] floatValue]>cell.beginTimeLabel.y+60) {
//        cell.openButton.hidden=NO;
//    }else{
//        cell.openButton.hidden=YES;
//    }
    
    //委托人和公出信息
    if (model.isOpen&&cell.openButton.hidden==NO) {
            //公出信息
        if ([self.businessCode isEqualToString:@"GC0009"]) {
            [self addGoOutCellInfoWithModel:model cell:cell indexPath:indexPath];
        }else if ([self.businessCode isEqualToString:@"JB0011"]){
            //加班
            [self addPersonWorkCellInfoWithModel:model cell:cell indexPath:indexPath];
        }else if([self.businessCode isEqualToString:@"YC0012"]){
            //实际打卡时间
            if (model.content2.length>0) {
                cell.businessCountLabel.hidden=NO;
                cell.businessCountLabel.y=cell.reasonLabel.y+cell.reasonLabel.height;
                cell.businessCountLabel.height=20;
                
                cell.holidayCountLabel.hidden=NO;
                cell.holidayCountLabel.y=cell.businessCountLabel.y+cell.businessCountLabel.height;
                cell.holidayCountLabel.height=20;
                cell.holidayCountLabel.text=model.content2;
            }
        }else{
            //请假
            [self addHolidaysCellInfoWithModel:model cell:cell indexPath:indexPath];
        }
        if (model.workEntrustList.count>0) {
            //如果workArr数组没有数据 则加载
            if (self.workDict.allKeys.count==0) {
                [self addPersonCellInfoWithModel:model cell:cell indexPath:indexPath];
            }
        }
    }else{
        //如果是公出异常
        if([self.businessCode isEqualToString:@"YC0012"]){
            //实际打卡时间
            if (model.content2.length>0) {
                cell.businessCountLabel.hidden=YES;
                cell.businessCountLabel.height=0;
                
                cell.holidayCountLabel.hidden=YES;
                cell.holidayCountLabel.height=0;
            }
        }
        //如果折叠则移除
        for (int i=0; i<self.workDict.allKeys.count; i++) {
            if ([[NSString stringWithFormat:@"cell%ld",indexPath.row] isEqualToString:self.workDict.allKeys[i]]) {
                NSMutableArray *workArr=self.workDict[self.workDict.allKeys[i]];
                for (UILabel *label in workArr) {
                    [label removeFromSuperview];
                }
                [self.workDict removeObjectForKey:[NSString stringWithFormat:@"cell%ld",indexPath.row]];
            }
        }
        //如果有照片  则要移除
        if (model.eliminateApproveList.count>0&&self.photoArr.count>0) {
            for (UIButton *photo in self.photoArr) {
                [photo removeFromSuperview];
            }
            [self.photoArr removeAllObjects];
        }
    }

}

#pragma mark -公出的信息
- (void)addGoOutCellInfoWithModel:(TaskDetailModel *)model cell:(TaskDetailTableViewCell *)cell indexPath:(NSIndexPath *)indexPath{
    //保存公出信息的数组
    NSMutableArray *goOutArr=[NSMutableArray new];
    //调整布局
    cell.businessCountLabel.y=cell.reasonLabel.y+cell.reasonLabel.height+8;
    cell.holidayCountLabel.y=cell.businessCountLabel.y+cell.businessCountLabel.height;
    cell.yearHolidayLabel.y=cell.holidayCountLabel.y+cell.holidayCountLabel.height;
    //公出人员
    UILabel  *personLabel=[MyControl creatLabelWithFrame:CGRectMake(cell.yearHolidayLabel.x, cell.yearHolidayLabel.y+cell.yearHolidayLabel.height, cell.yearHolidayLabel.width, 00) text:[NSString stringWithFormat:@"公出人员：%@",model.content1]];
    //如果有内容才给与高度
    if (model.content1.length>0) {
        personLabel.height=20;
    }
    personLabel.font=FONT_12;
    //taskLabel.hidden=NO;
    personLabel.textColor=[UIColor grayColor];
    [cell.contentView addSubview:personLabel];
    [goOutArr addObject:personLabel];
    //公出地址
    UILabel  *addressLabel=[MyControl creatLabelWithFrame:CGRectMake(cell.yearHolidayLabel.x, personLabel.y+personLabel.height, cell.yearHolidayLabel.width, 0) text:model.content2];
    //如果有内容才给与高度
    if (model.content2.length>0) {
        addressLabel.height=20;
    }
    addressLabel.font=FONT_12;
    //taskLabel.hidden=NO;
    addressLabel.textColor=[UIColor grayColor];
    [cell.contentView addSubview:addressLabel];
    [goOutArr addObject:addressLabel];
    //携带物品
    UILabel  *goOutLabel=[MyControl creatLabelWithFrame:CGRectMake(cell.yearHolidayLabel.x, addressLabel.y+addressLabel.height, cell.yearHolidayLabel.width, 0) text:model.content3];
    //如果有内容才给与高度
    if (model.content3.length>0) {
        goOutLabel.height=20;
    }
    goOutLabel.font=FONT_12;
    //taskLabel.hidden=NO;
    goOutLabel.textColor=[UIColor grayColor];
    [cell.contentView addSubview:goOutLabel];
    [goOutArr addObject:goOutLabel];
    [self.workDict setObject:goOutArr forKey:[NSString stringWithFormat:@"cell%ld",indexPath.row]];
    //公出行程
    for (int i=0; i<model.workEntrustList.count; i++) {
        NSMutableArray *labelArr=[NSMutableArray new];
        TaskDetailModel *workModel=model.workEntrustList[i];
        //行程
        UILabel  *nameLabel=[MyControl creatLabelWithFrame:CGRectMake(cell.yearHolidayLabel.x, goOutLabel.y+goOutLabel.height+8+60*i, cell.yearHolidayLabel.width, 20) text:[NSString stringWithFormat:@"%@：%@ 至 %@",workModel.entrustId,workModel.entrustBeginTime,workModel.entrustEndTime]];
        nameLabel.font=FONT_12;
        //nameLabel.hidden=NO;
        nameLabel.textColor=[UIColor grayColor];
        //nameLabel.backgroundColor=[UIColor redColor];
        [cell.contentView addSubview:nameLabel];
        [labelArr addObject:nameLabel];
        //乘车方式
        UILabel  *daysLabel=[MyControl creatLabelWithFrame:CGRectMake(cell.yearHolidayLabel.x, nameLabel.y+nameLabel.height, cell.yearHolidayLabel.width, 20) text:[NSString stringWithFormat:@"乘车方式：%@",workModel.taskDescribe]];
        daysLabel.font=FONT_12;
        //startTimeLabel.hidden=NO;
        daysLabel.textColor=[UIColor grayColor];
        [cell.contentView addSubview:daysLabel];
        [labelArr addObject:daysLabel];
        //乘车费用
        UILabel  *personLabel=[MyControl creatLabelWithFrame:CGRectMake(cell.yearHolidayLabel.x, daysLabel.y+daysLabel.height, cell.yearHolidayLabel.width, 20) text:[NSString stringWithFormat:@"乘车费用：%@元",workModel.entrustMan]];
        personLabel.font=FONT_12;
        //taskLabel.hidden=NO;
        personLabel.textColor=[UIColor grayColor];
        [cell.contentView addSubview:personLabel];
        [labelArr addObject:personLabel];
        [self.workDict setObject:labelArr forKey:[NSString stringWithFormat:@"cell%ld",indexPath.row]];
    }
    //如果有照片
    if (model.eliminateApproveList.count>0&&cell.openButton.hidden==NO) {
        //先移除掉
        if (self.photoArr.count>0) {
            for (UIButton *photo in self.photoArr) {
                [photo removeFromSuperview];
            }
            [self.photoArr removeAllObjects];
        }
        for (int i=0; i<model.eliminateApproveList.count; i++) {
            //        NSMutableArray *labelArr=[NSMutableArray new];
            TaskDetailModel *workModel=model.eliminateApproveList[i];
            //行程
            UIButton *photoBtn=[UIButton buttonWithType:UIButtonTypeCustom];
            //这里的高度要把行程的高度计算在内
            photoBtn.frame=CGRectMake(cell.yearHolidayLabel.x, (goOutLabel.y+goOutLabel.height+8+60*model.workEntrustList.count)+20*i, cell.yearHolidayLabel.width, 20);
            [photoBtn setTitle:workModel.eliminatePicName forState:UIControlStateNormal];
            photoBtn.titleLabel.font=FONT_13;
            photoBtn.contentHorizontalAlignment=UIControlContentHorizontalAlignmentLeft;
            [photoBtn setTitleColor:COLOR_MIDBLUE forState:UIControlStateNormal];
            [photoBtn addTarget:self action:@selector(photoClick:) forControlEvents:UIControlEventTouchUpInside];
            [cell.contentView addSubview:photoBtn];
            [self.photoArr addObject:photoBtn];
        }
        self.photoModelArr=model.eliminateApproveList;
    }

}

#pragma mark -委托人信息
- (void)addPersonCellInfoWithModel:(TaskDetailModel *)model cell:(TaskDetailTableViewCell *)cell indexPath:(NSIndexPath *)indexPath{
    for (int i=0; i<model.workEntrustList.count; i++) {
        NSMutableArray *labelArr=[NSMutableArray new];
        TaskDetailModel *workModel=model.workEntrustList[i];
        //委托人
        UILabel  *nameLabel=[MyControl creatLabelWithFrame:CGRectMake(cell.yearHolidayLabel.x, cell.yearHolidayLabel.y+cell.yearHolidayLabel.height+8+60*i, cell.yearHolidayLabel.width, 20) text:[NSString stringWithFormat:@"委托人：%@",workModel.entrustMan]];
        nameLabel.font=FONT_12;
        //nameLabel.hidden=NO;
        nameLabel.textColor=[UIColor grayColor];
        //nameLabel.backgroundColor=[UIColor redColor];
        [cell.contentView addSubview:nameLabel];
        [labelArr addObject:nameLabel];
        //委托时间
        NSString *beginStr=[LZXHelper getTimeStrWithOldDateFomatter:@"yyyy-MM-dd HH:mm" DateStr:workModel.entrustBeginTime newFormatter:@"MM-dd HH:mm"];
        NSString *endStr=[LZXHelper getTimeStrWithOldDateFomatter:@"yyyy-MM-dd HH:mm" DateStr:workModel.entrustBeginTime newFormatter:@"MM-dd HH:mm"];
        UILabel  *startTimeLabel=[MyControl creatLabelWithFrame:CGRectMake(cell.yearHolidayLabel.x, nameLabel.y+nameLabel.height, cell.yearHolidayLabel.width, 20) text:[NSString stringWithFormat:@"委托时间：%@至%@",beginStr,endStr]];
        startTimeLabel.font=FONT_12;
        //startTimeLabel.hidden=NO;
        startTimeLabel.textColor=[UIColor grayColor];
        [cell.contentView addSubview:startTimeLabel];
        [labelArr addObject:startTimeLabel];
        //委托任务
        UILabel  *taskLabel=[MyControl creatLabelWithFrame:CGRectMake(cell.yearHolidayLabel.x, startTimeLabel.y+startTimeLabel.height, cell.yearHolidayLabel.width, 20) text:[NSString stringWithFormat:@"委托任务：%@",workModel.taskDescribe]];
        taskLabel.font=FONT_12;
        //taskLabel.hidden=NO;
        taskLabel.textColor=[UIColor grayColor];
        [cell.contentView addSubview:taskLabel];
        [labelArr addObject:taskLabel];
        [self.workDict setObject:labelArr forKey:[NSString stringWithFormat:@"cell%ld",indexPath.row]];
    }

}

#pragma mark -加班信息

- (void)addPersonWorkCellInfoWithModel:(TaskDetailModel *)model cell:(TaskDetailTableViewCell *)cell indexPath:(NSIndexPath *)indexPath{
    NSMutableArray *goOutArr=[NSMutableArray new];
    //加班人员
    UILabel  *personLabel=[MyControl creatLabelWithFrame:CGRectMake(cell.yearHolidayLabel.x, cell.yearHolidayLabel.y+cell.yearHolidayLabel.height, cell.yearHolidayLabel.width, 00) text:[NSString stringWithFormat:@"加班人员：%@",model.content1]];
    //如果有内容才给与高度
    if (model.content1.length>0) {
        personLabel.height=20;
    }
    personLabel.font=FONT_12;
    //taskLabel.hidden=NO;
    personLabel.textColor=[UIColor grayColor];
    [cell.contentView addSubview:personLabel];
    [goOutArr addObject:personLabel];
    //加班地址
    UILabel  *addressLabel=[MyControl creatLabelWithFrame:CGRectMake(cell.yearHolidayLabel.x, personLabel.y+personLabel.height, cell.yearHolidayLabel.width, 0) text:model.content2];
    //如果有内容才给与高度
    if (model.content2.length>0) {
        addressLabel.height=20;
    }
    addressLabel.font=FONT_12;
    //taskLabel.hidden=NO;
    addressLabel.textColor=[UIColor grayColor];
    [cell.contentView addSubview:addressLabel];
    [goOutArr addObject:addressLabel];
}

#pragma mark -请假信息

- (void)addHolidaysCellInfoWithModel:(TaskDetailModel *)model cell:(TaskDetailTableViewCell *)cell indexPath:(NSIndexPath *)indexPath{

    //如果有照片
    if (model.eliminateApproveList.count>0&&cell.openButton.hidden==NO) {
        //先移除掉
        if (self.photoArr.count>0) {
            for (UIButton *photo in self.photoArr) {
                [photo removeFromSuperview];
            }
            [self.photoArr removeAllObjects];
        }
        for (int i=0; i<model.eliminateApproveList.count; i++) {
            //        NSMutableArray *labelArr=[NSMutableArray new];
            TaskDetailModel *workModel=model.eliminateApproveList[i];
            //行程
            UIButton *photoBtn=[UIButton buttonWithType:UIButtonTypeCustom];
            //这里的高度要把行程的高度计算在内
            photoBtn.frame=CGRectMake(cell.beginTimeLabel.x, (cell.reasonLabel.y+cell.reasonLabel.height+8+60*model.workEntrustList.count)+20*i, cell.yearHolidayLabel.width, 20);
            [photoBtn setTitle:workModel.eliminatePicName forState:UIControlStateNormal];
            photoBtn.titleLabel.font=FONT_13;
            photoBtn.contentHorizontalAlignment=UIControlContentHorizontalAlignmentLeft;
            [photoBtn setTitleColor:COLOR_MIDBLUE forState:UIControlStateNormal];
            [photoBtn addTarget:self action:@selector(photoClick:) forControlEvents:UIControlEventTouchUpInside];
            [cell.contentView addSubview:photoBtn];
            [self.photoArr addObject:photoBtn];
        }
        self.photoModelArr=model.eliminateApproveList;
    }
}

#pragma mark -计算cell的高度
- (void)calculateCellHeight{
    for (TaskDetailModel *model in _taskDetailModel.dataArr) {
        CGFloat cellHeight=48;
        //根据有没有内容来计算高度
        if (model.startTime.length>0||model.eliminateStartTime.length>0) {
            cellHeight+=20;
        }
        if (model.endTime.length>0||model.eliminateEndTime.length>0) {
            cellHeight+=20;
        }
        //根据时间判断是不是超时 超时高度增加20
        if (model.timeoutLength.integerValue<0){
            cellHeight+=20;
        }
        
        if (model.cause.length>0) {
            cellHeight+=20;
        }
        
        if (model.vacateBillId.length>0) {
            cellHeight+=20;
        }
        if (model.vacateDays.length>0) {
            cellHeight+=20;
        }
        if (model.yearsCounteract.length>0) {
            cellHeight+=20;
        }
//        //以下内容只在row==0时执行
//        if ([_taskDetailModel.dataArr indexOfObject:model]!=0) {
//            return;
//        }
        if ([self.businessCode isEqualToString:@"YC0012"]) {
            if (model.startTime.length>0) {
                cellHeight+=20;
            }
        }
        //如果是公出申请 则要计算公出信息的高度
        if ([self.businessCode isEqualToString:@"GC0009"]) {
            if (model.content1.length>0) {
                cellHeight+=20;
            }
            if (model.content2.length>0) {
                cellHeight+=20;
            }
            if (model.content3.length>0) {
                cellHeight+=20;
            }
            //间隔距离为8
            cellHeight+=8;
        }
        //如果有照片 则计算照片的高度
        if (model.eliminateApproveList.count>0) {
            cellHeight+=20*model.eliminateApproveList.count;
        }
        //如果是加班申请 则要计算加班信息的高度
        if ([self.businessCode isEqualToString:@"JB0011"]){
            if (model.content1.length>0) {
                cellHeight+=20;
            }
            if (model.content2.length>0) {
                cellHeight+=20;
            }

        }
        //计算委托人或者公出行程的高度
        if (model.workEntrustList.count>0) {
            cellHeight+=60*model.workEntrustList.count+8;
        }
        cellHeight+=8;
        [self.heightArr addObject:[NSNumber numberWithFloat:cellHeight]];
    }
}

#pragma mark -审批历程（时间轴）

- (void)getApproveCourseListRequest{
    [LZXHelper postLoadViewWithText:HUD_PLEASEWAIT View:self.view];
    NSDictionary *dict=@{
                         @"businessCode":_businessCode?_businessCode:@"",
                         @"vacateBillId":self.vacateBillId?self.vacateBillId:@""
                         };

    //   字典转json
    NSData* jsonData = [NSJSONSerialization dataWithJSONObject:dict options:NSJSONWritingPrettyPrinted error:nil];
    NSString* str = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
    //拼接soap字符串
    NSString* soap = [NSString stringWithFormat:@"<sessionId>%@</sessionId>\n<content>%@</content>",[LZXHelper getSessionID],str];
    // __weak AddressBookViewController *mySelf=self;
    [HttpRequest SOAPData:[LZXHelper getServerURL] SoapMthod:getApproveCourseList soapBody:soap success:^(id responseObject) {
        [LZXHelper hideLoadViewWithView:self.view];
        
        //解析数据
        _taskDetailModel=[[TaskDetailModel alloc]initWithResponse:responseObject];
        if ([_taskDetailModel.code isEqualToString:@"200"]) {
            [self calculateCellHeight];
            [self creatHeaderView];
            [_tableView reloadData];
        }else if([_taskDetailModel.code isEqualToString:@"220"]){
            [LZXHelper postMessageWithText:_taskDetailModel.msg View:self.view];
        }
    } failure:^(NSError *error) {
        [LZXHelper hideLoadViewWithView:self.view];
    }];
}

#pragma mark -获取制度详细信息请求

- (void)getManagementInfoRequest{
    NSDictionary *dict=@{
                         @"businessCode":_businessCode?_businessCode:@"",
                         };
    
    //   字典转json
    NSData* jsonData = [NSJSONSerialization dataWithJSONObject:dict options:NSJSONWritingPrettyPrinted error:nil];
    NSString* str = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
    //拼接soap字符串
    NSString* soap = [NSString stringWithFormat:@"<sessionId>%@</sessionId>\n<content>%@</content>",[LZXHelper getSessionID],str];
    //[LZXHelper postLoadViewWithText:HUD_PLEASEWAIT View:self.view];
    // __weak AddressBookViewController *mySelf=self;
    [HttpRequest SOAPData:[LZXHelper getServerURL] SoapMthod:getManagementInfo soapBody:soap success:^(id responseObject) {
        //[LZXHelper hideLoadViewWithView:self.view];
        
        //解析数据
        _institutionListModel=[[InstitutionListModel alloc]initWithResponse:responseObject];
        if ([_institutionListModel.code isEqualToString:@"200"]) {

        }else if([_institutionListModel.code isEqualToString:@"220"]){
            //[LZXHelper postMessageWithText:_model.msg View:self.view];
        }
    } failure:^(NSError *error) {
        //[LZXHelper hideLoadViewWithView:self.view];
    }];
}

#pragma mark -获取倒计时间请求

- (void)getCountdownTimeInfoRequest{
    
    NSDictionary *dict=@{
                         @"businessCode":_businessCode?_businessCode:@"",
                         @"LeaveTypePK":_keywordId?_keywordId:@"",
                         @"type":self.type?self.type:@""
                         };
    
    //   字典转json
    NSData* jsonData = [NSJSONSerialization dataWithJSONObject:dict options:NSJSONWritingPrettyPrinted error:nil];
    NSString* str = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
    //拼接soap字符串
    NSString* soap = [NSString stringWithFormat:@"<sessionId>%@</sessionId>\n<content>%@</content>",[LZXHelper getSessionID],str];
    // __weak AddressBookViewController *mySelf=self;
    //[LZXHelper postLoadViewWithText:HUD_PLEASEWAIT View:self.view];
    [HttpRequest SOAPData:[LZXHelper getServerURL] SoapMthod:getCountdownTimeInfo soapBody:soap success:^(id responseObject) {
        //[LZXHelper hideLoadViewWithView:self.view];
        
        //解析数据
        BasicModel *_model=[[BasicModel alloc]initWithResponse:responseObject];
        if ([_model.code isEqualToString:@"200"]) {
            NSDictionary *dict=responseObject[@"retContent"];
            NSInteger holidayCount=[dict[@"TimeLength"] integerValue];
            if (holidayCount%60>0) {
                //初始化时间
                _minute=holidayCount/60;
                //_minute=0;
                _second=holidayCount%60;
            }else{
                //初始化时间
                _minute=holidayCount/60-1;
                //_minute=0;
                _second=60;
            }
            _timer = [NSTimer scheduledTimerWithTimeInterval:1.0f target:self selector:@selector(timerFunc) userInfo:nil repeats:YES];
        }else if([_model.code isEqualToString:@"220"]){
            [LZXHelper postMessageWithText:_model.msg View:self.view];
        }
    } failure:^(NSError *error) {
        //[LZXHelper hideLoadViewWithView:self.view];
    }];
}


#pragma mark -请假审批/驳回接口

- (void)postApproveInfoRequestWithState:(NSString *)state{

    [LZXHelper postLoadViewWithText:HUD_PLEASEWAIT View:self.view];
    NSDictionary *vacateDict=@{
                               @"approveIdea":_msgTextView.text,
                               @"approveState":state?state:@"",
                               @"infoId":_taskDetailModel.infoId?_taskDetailModel.infoId:@"",
                               @"vacateBillId":self.vacateBillId?self.vacateBillId:@""
                               };
    NSArray *vacateArr=[NSArray arrayWithObject:vacateDict];
    NSDictionary *dict=@{
                         @"serviceTime":self.serviceTime?self.serviceTime:@"",
                         @"vacateBillList":vacateArr,
                         };
    
    //   字典转json
    NSData* jsonData = [NSJSONSerialization dataWithJSONObject:dict options:NSJSONWritingPrettyPrinted error:nil];
    NSString* str = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
    //拼接soap字符串
    NSString* soap = [NSString stringWithFormat:@"<sessionId>%@</sessionId>\n<content>%@</content>",[LZXHelper getSessionID],str];
    // __weak AddressBookViewController *mySelf=self;
    [HttpRequest SOAPData:[LZXHelper getServerURL] SoapMthod:postApproveInfo soapBody:soap success:^(id responseObject) {
        [LZXHelper hideLoadViewWithView:self.view];
        
        //解析数据
        BasicModel *model=[[BasicModel alloc]initWithResponse:responseObject];
        if ([model.code isEqualToString:@"220"]) {
            [LZXHelper postMessageWithText:model.msg View:[[UIApplication sharedApplication].delegate window]];
            [self backClick];
        }else if([model.code isEqualToString:@"200"]){
            [LZXHelper postMessageWithText:model.msg View:self.view];
        }
    } failure:^(NSError *error) {
        [LZXHelper hideLoadViewWithView:self.view];
    }];
}

#pragma mark -公出审批/驳回接口

- (void)postApproveNewFlowInfoRequestWithState:(NSString *)state{
    
    [LZXHelper postLoadViewWithText:HUD_PLEASEWAIT View:self.view];
    NSDictionary *vacateDict=@{
                               @"approveIdea":_msgTextView.text,
                               @"approveState":state?state:@"",
                               @"infoId":_taskDetailModel.infoId?_taskDetailModel.infoId:@"",
                               @"id":self.vacateBillId?self.vacateBillId:@"",
                               };
    NSArray *vacateArr=[NSArray arrayWithObject:vacateDict];
    NSDictionary *dict=@{
                         @"serviceTime":self.serviceTime?self.serviceTime:@"",
                         @"idList":vacateArr,
                         };
    
    //   字典转json
    NSData* jsonData = [NSJSONSerialization dataWithJSONObject:dict options:NSJSONWritingPrettyPrinted error:nil];
    NSString* str = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
    //拼接soap字符串
    NSString* soap = [NSString stringWithFormat:@"<sessionId>%@</sessionId>\n<content>%@</content>",[LZXHelper getSessionID],str];
    // __weak AddressBookViewController *mySelf=self;
    [HttpRequest SOAPData:[LZXHelper getServerURL] SoapMthod:postApproveNewFlowInfo soapBody:soap success:^(id responseObject) {
        [LZXHelper hideLoadViewWithView:self.view];
        
        //解析数据
        BasicModel *model=[[BasicModel alloc]initWithResponse:responseObject];
        if ([model.code isEqualToString:@"220"]) {
            [LZXHelper postMessageWithText:model.msg View:[[UIApplication sharedApplication].delegate window]];
            [self backClick];
        }else if([model.code isEqualToString:@"200"]){
            [LZXHelper postMessageWithText:model.msg View:self.view];
        }
    } failure:^(NSError *error) {
        [LZXHelper hideLoadViewWithView:self.view];
    }];
}

#pragma mark -提交公出汇报审核

- (void)postSHInfoRequestWithState:(NSString *)state{
    
    [LZXHelper postLoadViewWithText:HUD_PLEASEWAIT View:self.view];
    NSDictionary *vacateDict=@{
                               @"eliminateContent":_msgTextView.text,
                               @"eliminateType":state?state:@"",
                               @"infoId":_taskDetailModel.infoId?_taskDetailModel.infoId:@"",
                               @"id":self.vacateBillId?self.vacateBillId:@"",
                               @"serviceTime":self.serviceTime?self.serviceTime:@"",
                               };
    NSArray *vacateArr=[NSArray arrayWithObject:vacateDict];
    NSDictionary *dict=@{
                         @"idList":vacateArr,
                         };
    
    //   字典转json
    NSData* jsonData = [NSJSONSerialization dataWithJSONObject:dict options:NSJSONWritingPrettyPrinted error:nil];
    NSString* str = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
    //拼接soap字符串
    NSString* soap = [NSString stringWithFormat:@"<sessionId>%@</sessionId>\n<content>%@</content>",[LZXHelper getSessionID],str];
    // __weak AddressBookViewController *mySelf=self;
    [HttpRequest SOAPData:[LZXHelper getServerURL] SoapMthod:postSHInfo soapBody:soap success:^(id responseObject) {
        [LZXHelper hideLoadViewWithView:self.view];
        
        //解析数据
        BasicModel *model=[[BasicModel alloc]initWithResponse:responseObject];
        if ([model.code isEqualToString:@"220"]) {
            [LZXHelper postMessageWithText:model.msg View:[[UIApplication sharedApplication].delegate window]];
            [self backClick];
        }else if([model.code isEqualToString:@"200"]){
            [LZXHelper postMessageWithText:model.msg View:self.view];
        }
    } failure:^(NSError *error) {
        [LZXHelper hideLoadViewWithView:self.view];
    }];
}

#pragma mark -撤销请假接口

- (void)postDeleteVacateBillRequest{
    
    [LZXHelper postLoadViewWithText:HUD_PLEASEWAIT View:self.view];
    NSDictionary *dict=@{
                         @"vacateBillId":self.vacateBillId?self.vacateBillId:@""
                         };

    
    //   字典转json
    NSData* jsonData = [NSJSONSerialization dataWithJSONObject:dict options:NSJSONWritingPrettyPrinted error:nil];
    NSString* str = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
    //拼接soap字符串
    NSString* soap = [NSString stringWithFormat:@"<sessionId>%@</sessionId>\n<content>%@</content>",[LZXHelper getSessionID],str];
    // __weak AddressBookViewController *mySelf=self;
    [HttpRequest SOAPData:[LZXHelper getServerURL] SoapMthod:postDeleteVacateBill soapBody:soap success:^(id responseObject) {
        [LZXHelper hideLoadViewWithView:self.view];
        
        //解析数据
        BasicModel *model=[[BasicModel alloc]initWithResponse:responseObject];
        if ([model.code isEqualToString:@"200"]) {
            [LZXHelper postMessageWithText:model.msg View:[[UIApplication sharedApplication].delegate window]];
            [self backClick];
        }else if([model.code isEqualToString:@"220"]){
            [LZXHelper postMessageWithText:model.msg View:self.view];
        }
    } failure:^(NSError *error) {
        [LZXHelper hideLoadViewWithView:self.view];
    }];
}

#pragma mark -撤销公出加班接口

- (void)postDeleteBizRequest{
    
    [LZXHelper postLoadViewWithText:HUD_PLEASEWAIT View:self.view];
    NSDictionary *vacateDict=@{
//                               @"approveIdea":_msgTextView.text,
//                               @"approveState":state?state:@"",
//                               @"infoId":_taskDetailModel.infoId?_taskDetailModel.infoId:@"",
                               @"vacateBillId":self.vacateBillId?self.vacateBillId:@""
                               };
    NSArray *vacateArr=[NSArray arrayWithObject:vacateDict];
    NSDictionary *dict=@{
                         @"serviceTime":self.serviceTime?self.serviceTime:@"",
                         @"vacateBillList":vacateArr,
                         };
    
    
    //   字典转json
    NSData* jsonData = [NSJSONSerialization dataWithJSONObject:dict options:NSJSONWritingPrettyPrinted error:nil];
    NSString* str = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
    //拼接soap字符串
    NSString* soap = [NSString stringWithFormat:@"<sessionId>%@</sessionId>\n<content>%@</content>",[LZXHelper getSessionID],str];
    // __weak AddressBookViewController *mySelf=self;
    [HttpRequest SOAPData:[LZXHelper getServerURL] SoapMthod:postDeleteBiz soapBody:soap success:^(id responseObject) {
        [LZXHelper hideLoadViewWithView:self.view];
        
        //解析数据
        BasicModel *model=[[BasicModel alloc]initWithResponse:responseObject];
        if ([model.code isEqualToString:@"220"]) {
            [LZXHelper postMessageWithText:model.msg View:[[UIApplication sharedApplication].delegate window]];
            [self backClick];
        }else if([model.code isEqualToString:@"200"]){
            [LZXHelper postMessageWithText:model.msg View:self.view];
        }
    } failure:^(NSError *error) {
        [LZXHelper hideLoadViewWithView:self.view];
    }];
}

#pragma mark -提交核销确认信息

- (void)postVerifyEliminateInfoRequestWithState:(NSString *)state{
    
    [LZXHelper postLoadViewWithText:HUD_PLEASEWAIT View:self.view];
    NSDictionary *vacateDict=@{
                               @"verifyEliminateContent":_msgTextView.text,
                               @"verifyEliminateType":state?state:@"",
                               @"infoId":_taskDetailModel.infoId?_taskDetailModel.infoId:@"",
                               @"vacateBillId":self.vacateBillId?self.vacateBillId:@"",
                               @"serviceTime":self.serviceTime?self.serviceTime:@"",
                               };
    NSArray *vacateArr=[NSArray arrayWithObject:vacateDict];
    NSDictionary *dict=@{
                         @"vacateBillList":vacateArr,
                         };
    
    //   字典转json
    NSData* jsonData = [NSJSONSerialization dataWithJSONObject:dict options:NSJSONWritingPrettyPrinted error:nil];
    NSString* str = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
    //拼接soap字符串
    NSString* soap = [NSString stringWithFormat:@"<sessionId>%@</sessionId>\n<content>%@</content>",[LZXHelper getSessionID],str];
    // __weak AddressBookViewController *mySelf=self;
    [HttpRequest SOAPData:[LZXHelper getServerURL] SoapMthod:postVerifyEliminateInfo soapBody:soap success:^(id responseObject) {
        [LZXHelper hideLoadViewWithView:self.view];
        
        //解析数据
        BasicModel *model=[[BasicModel alloc]initWithResponse:responseObject];
        if ([model.code isEqualToString:@"220"]) {
            [LZXHelper postMessageWithText:model.msg View:[[UIApplication sharedApplication].delegate window]];
            [self backClick];
        }else if([model.code isEqualToString:@"200"]){
            [LZXHelper postMessageWithText:model.msg View:self.view];
        }
    } failure:^(NSError *error) {
        [LZXHelper hideLoadViewWithView:self.view];
    }];
}

#pragma mark -获取当前时间请求

- (void)serverDateRequest{
    //[LZXHelper postLoadViewWithText:HUD_PLEASEWAIT View:self.view];
    
    NSString* soap = [NSString stringWithFormat:@"<sessionId>%@</sessionId>\n<content></content>",[LZXHelper getSessionID]];
    // __weak AddressBookViewController *mySelf=self;
    [HttpRequest SOAPData:[LZXHelper getServerURL] SoapMthod:getServiceTime soapBody:soap success:^(id responseObject) {
        //[LZXHelper hideLoadViewWithView:self.view];
        
        //解析数据
        BasicModel *model=[[BasicModel alloc]initWithResponse:responseObject];
        if ([model.code isEqualToString:@"200"]) {
            NSDictionary *dataDict=responseObject[@"retContent"];
            self.serviceTime=[dataDict[@"serviceTime"] copy];
            
            //判断撤销  延假 销假
            if (!([self.businessCode isEqualToString:@"GC0009"]||[self.businessCode isEqualToString:@"YC0012"]||[self.businessCode isEqualToString:@"JB0011"])&&[self.isOperate isEqualToString:@"1"]) {
                if ([self.dealState isEqualToString:@"3"]||[self.dealState isEqualToString:@"4"]) {
                    //格式化字符串
                    NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
                    [dateFormatter setDateFormat:@"yyyy-MM-dd HH:mm"];
                    NSDate *dateA = [dateFormatter dateFromString:self.beginStr];
                    NSDate *dateC = [dateFormatter dateFromString:self.endStr];
                    [dateFormatter setDateFormat:@"yyyy-MM-dd HH:mm:ss"];
                    NSDate *dateB = [dateFormatter dateFromString:self.serviceTime];
                    NSComparisonResult resultA = [dateA compare:dateB];
                    NSComparisonResult resultB = [dateC compare:dateB];
                    if (resultA==NSOrderedAscending&&resultB==NSOrderedAscending) {
                        //销假
                        [self creatEndHolidayTextView];
                    }else if (resultA==NSOrderedDescending&&resultB==NSOrderedDescending){
                        //撤销
                        [self creatCancelTextView];
                    }else{
                        //延假
                        [self creatAddHolidayTextView];
                    }
                }
                
            }

        }else if([model.code isEqualToString:@"220"]){
            [LZXHelper postMessageWithText:model.msg View:self.view];
        }
    } failure:^(NSError *error) {
        //[LZXHelper hideLoadViewWithView:self.view];
    }];
}



- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
